<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - test/gmock-1.7.0/gtest/include/gtest/internal/gtest-port.h</title>
  <link rel="stylesheet" type="text/css" href="../../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../../../index.html">top level</a> - <a href="index.html">test/gmock-1.7.0/gtest/include/gtest/internal</a> - gtest-port.h<span style="font-size: 80%;"> (source / <a href="gtest-port.h.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">115</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">107</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr><td><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Copyright 2005, Google Inc.</a>
<span class="lineNum">       2 </span>            : // All rights reserved.
<span class="lineNum">       3 </span>            : //
<span class="lineNum">       4 </span>            : // Redistribution and use in source and binary forms, with or without
<span class="lineNum">       5 </span>            : // modification, are permitted provided that the following conditions are
<span class="lineNum">       6 </span>            : // met:
<span class="lineNum">       7 </span>            : //
<span class="lineNum">       8 </span>            : //     * Redistributions of source code must retain the above copyright
<span class="lineNum">       9 </span>            : // notice, this list of conditions and the following disclaimer.
<span class="lineNum">      10 </span>            : //     * Redistributions in binary form must reproduce the above
<span class="lineNum">      11 </span>            : // copyright notice, this list of conditions and the following disclaimer
<span class="lineNum">      12 </span>            : // in the documentation and/or other materials provided with the
<span class="lineNum">      13 </span>            : // distribution.
<span class="lineNum">      14 </span>            : //     * Neither the name of Google Inc. nor the names of its
<span class="lineNum">      15 </span>            : // contributors may be used to endorse or promote products derived from
<span class="lineNum">      16 </span>            : // this software without specific prior written permission.
<span class="lineNum">      17 </span>            : //
<span class="lineNum">      18 </span>            : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
<span class="lineNum">      19 </span>            : // &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
<span class="lineNum">      20 </span>            : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
<span class="lineNum">      21 </span>            : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
<span class="lineNum">      22 </span>            : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
<span class="lineNum">      23 </span>            : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
<span class="lineNum">      24 </span>            : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
<span class="lineNum">      25 </span>            : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<span class="lineNum">      26 </span>            : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<span class="lineNum">      27 </span>            : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<span class="lineNum">      28 </span>            : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<span class="lineNum">      29 </span>            : //
<span class="lineNum">      30 </span>            : // Authors: wan@google.com (Zhanyong Wan)
<span class="lineNum">      31 </span>            : //
<span class="lineNum">      32 </span>            : // Low-level types and utilities for porting Google Test to various
<span class="lineNum">      33 </span>            : // platforms.  They are subject to change without notice.  DO NOT USE
<span class="lineNum">      34 </span>            : // THEM IN USER CODE.
<span class="lineNum">      35 </span>            : //
<span class="lineNum">      36 </span>            : // This file is fundamental to Google Test.  All other Google Test source
<span class="lineNum">      37 </span>            : // files are expected to #include this.  Therefore, it cannot #include
<span class="lineNum">      38 </span>            : // any other Google Test header.
<span class="lineNum">      39 </span>            : 
<span class="lineNum">      40 </span>            : #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
<span class="lineNum">      41 </span>            : #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
<span class="lineNum">      42 </span>            : 
<span class="lineNum">      43 </span>            : // The user can define the following macros in the build script to
<span class="lineNum">      44 </span>            : // control Google Test's behavior.  If the user doesn't define a macro
<span class="lineNum">      45 </span>            : // in this list, Google Test will define it.
<span class="lineNum">      46 </span>            : //
<span class="lineNum">      47 </span>            : //   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)
<span class="lineNum">      48 </span>            : //                              is/isn't available.
<span class="lineNum">      49 </span>            : //   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions
<span class="lineNum">      50 </span>            : //                              are enabled.
<span class="lineNum">      51 </span>            : //   GTEST_HAS_GLOBAL_STRING  - Define it to 1/0 to indicate that ::string
<span class="lineNum">      52 </span>            : //                              is/isn't available (some systems define
<span class="lineNum">      53 </span>            : //                              ::string, which is different to std::string).
<span class="lineNum">      54 </span>            : //   GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
<span class="lineNum">      55 </span>            : //                              is/isn't available (some systems define
<span class="lineNum">      56 </span>            : //                              ::wstring, which is different to std::wstring).
<span class="lineNum">      57 </span>            : //   GTEST_HAS_POSIX_RE       - Define it to 1/0 to indicate that POSIX regular
<span class="lineNum">      58 </span>            : //                              expressions are/aren't available.
<span class="lineNum">      59 </span>            : //   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that &lt;pthread.h&gt;
<span class="lineNum">      60 </span>            : //                              is/isn't available.
<span class="lineNum">      61 </span>            : //   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't
<span class="lineNum">      62 </span>            : //                              enabled.
<span class="lineNum">      63 </span>            : //   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that
<span class="lineNum">      64 </span>            : //                              std::wstring does/doesn't work (Google Test can
<span class="lineNum">      65 </span>            : //                              be used where std::wstring is unavailable).
<span class="lineNum">      66 </span>            : //   GTEST_HAS_TR1_TUPLE      - Define it to 1/0 to indicate tr1::tuple
<span class="lineNum">      67 </span>            : //                              is/isn't available.
<span class="lineNum">      68 </span>            : //   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the
<span class="lineNum">      69 </span>            : //                              compiler supports Microsoft's &quot;Structured
<span class="lineNum">      70 </span>            : //                              Exception Handling&quot;.
<span class="lineNum">      71 </span>            : //   GTEST_HAS_STREAM_REDIRECTION
<span class="lineNum">      72 </span>            : //                            - Define it to 1/0 to indicate whether the
<span class="lineNum">      73 </span>            : //                              platform supports I/O stream redirection using
<span class="lineNum">      74 </span>            : //                              dup() and dup2().
<span class="lineNum">      75 </span>            : //   GTEST_USE_OWN_TR1_TUPLE  - Define it to 1/0 to indicate whether Google
<span class="lineNum">      76 </span>            : //                              Test's own tr1 tuple implementation should be
<span class="lineNum">      77 </span>            : //                              used.  Unused when the user sets
<span class="lineNum">      78 </span>            : //                              GTEST_HAS_TR1_TUPLE to 0.
<span class="lineNum">      79 </span>            : //   GTEST_LANG_CXX11         - Define it to 1/0 to indicate that Google Test
<span class="lineNum">      80 </span>            : //                              is building in C++11/C++98 mode.
<span class="lineNum">      81 </span>            : //   GTEST_LINKED_AS_SHARED_LIBRARY
<span class="lineNum">      82 </span>            : //                            - Define to 1 when compiling tests that use
<span class="lineNum">      83 </span>            : //                              Google Test as a shared library (known as
<span class="lineNum">      84 </span>            : //                              DLL on Windows).
<span class="lineNum">      85 </span>            : //   GTEST_CREATE_SHARED_LIBRARY
<span class="lineNum">      86 </span>            : //                            - Define to 1 when compiling Google Test itself
<span class="lineNum">      87 </span>            : //                              as a shared library.
<span class="lineNum">      88 </span>            : 
<span class="lineNum">      89 </span>            : // This header defines the following utilities:
<span class="lineNum">      90 </span>            : //
<span class="lineNum">      91 </span>            : // Macros indicating the current platform (defined to 1 if compiled on
<span class="lineNum">      92 </span>            : // the given platform; otherwise undefined):
<span class="lineNum">      93 </span>            : //   GTEST_OS_AIX      - IBM AIX
<span class="lineNum">      94 </span>            : //   GTEST_OS_CYGWIN   - Cygwin
<span class="lineNum">      95 </span>            : //   GTEST_OS_HPUX     - HP-UX
<span class="lineNum">      96 </span>            : //   GTEST_OS_LINUX    - Linux
<span class="lineNum">      97 </span>            : //     GTEST_OS_LINUX_ANDROID - Google Android
<span class="lineNum">      98 </span>            : //   GTEST_OS_MAC      - Mac OS X
<span class="lineNum">      99 </span>            : //     GTEST_OS_IOS    - iOS
<span class="lineNum">     100 </span>            : //       GTEST_OS_IOS_SIMULATOR - iOS simulator
<span class="lineNum">     101 </span>            : //   GTEST_OS_NACL     - Google Native Client (NaCl)
<span class="lineNum">     102 </span>            : //   GTEST_OS_OPENBSD  - OpenBSD
<span class="lineNum">     103 </span>            : //   GTEST_OS_QNX      - QNX
<span class="lineNum">     104 </span>            : //   GTEST_OS_SOLARIS  - Sun Solaris
<span class="lineNum">     105 </span>            : //   GTEST_OS_SYMBIAN  - Symbian
<span class="lineNum">     106 </span>            : //   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)
<span class="lineNum">     107 </span>            : //     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop
<span class="lineNum">     108 </span>            : //     GTEST_OS_WINDOWS_MINGW    - MinGW
<span class="lineNum">     109 </span>            : //     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile
<span class="lineNum">     110 </span>            : //   GTEST_OS_ZOS      - z/OS
<span class="lineNum">     111 </span>            : //
<span class="lineNum">     112 </span>            : // Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
<span class="lineNum">     113 </span>            : // most stable support.  Since core members of the Google Test project
<span class="lineNum">     114 </span>            : // don't have access to other platforms, support for them may be less
<span class="lineNum">     115 </span>            : // stable.  If you notice any problems on your platform, please notify
<span class="lineNum">     116 </span>            : // googletestframework@googlegroups.com (patches for fixing them are
<span class="lineNum">     117 </span>            : // even more welcome!).
<span class="lineNum">     118 </span>            : //
<span class="lineNum">     119 </span>            : // Note that it is possible that none of the GTEST_OS_* macros are defined.
<span class="lineNum">     120 </span>            : //
<span class="lineNum">     121 </span>            : // Macros indicating available Google Test features (defined to 1 if
<span class="lineNum">     122 </span>            : // the corresponding feature is supported; otherwise undefined):
<span class="lineNum">     123 </span>            : //   GTEST_HAS_COMBINE      - the Combine() function (for value-parameterized
<span class="lineNum">     124 </span>            : //                            tests)
<span class="lineNum">     125 </span>            : //   GTEST_HAS_DEATH_TEST   - death tests
<span class="lineNum">     126 </span>            : //   GTEST_HAS_PARAM_TEST   - value-parameterized tests
<span class="lineNum">     127 </span>            : //   GTEST_HAS_TYPED_TEST   - typed tests
<span class="lineNum">     128 </span>            : //   GTEST_HAS_TYPED_TEST_P - type-parameterized tests
<span class="lineNum">     129 </span>            : //   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used. Do not confuse with
<span class="lineNum">     130 </span>            : //                            GTEST_HAS_POSIX_RE (see above) which users can
<span class="lineNum">     131 </span>            : //                            define themselves.
<span class="lineNum">     132 </span>            : //   GTEST_USES_SIMPLE_RE   - our own simple regex is used;
<span class="lineNum">     133 </span>            : //                            the above two are mutually exclusive.
<span class="lineNum">     134 </span>            : //   GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
<span class="lineNum">     135 </span>            : //
<span class="lineNum">     136 </span>            : // Macros for basic C++ coding:
<span class="lineNum">     137 </span>            : //   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
<span class="lineNum">     138 </span>            : //   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a
<span class="lineNum">     139 </span>            : //                              variable don't have to be used.
<span class="lineNum">     140 </span>            : //   GTEST_DISALLOW_ASSIGN_   - disables operator=.
<span class="lineNum">     141 </span>            : //   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
<span class="lineNum">     142 </span>            : //   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.
<span class="lineNum">     143 </span>            : //
<span class="lineNum">     144 </span>            : // Synchronization:
<span class="lineNum">     145 </span>            : //   Mutex, MutexLock, ThreadLocal, GetThreadCount()
<span class="lineNum">     146 </span>            : //                  - synchronization primitives.
<span class="lineNum">     147 </span>            : //   GTEST_IS_THREADSAFE - defined to 1 to indicate that the above
<span class="lineNum">     148 </span>            : //                         synchronization primitives have real implementations
<span class="lineNum">     149 </span>            : //                         and Google Test is thread-safe; or 0 otherwise.
<span class="lineNum">     150 </span>            : //
<span class="lineNum">     151 </span>            : // Template meta programming:
<span class="lineNum">     152 </span>            : //   is_pointer     - as in TR1; needed on Symbian and IBM XL C/C++ only.
<span class="lineNum">     153 </span>            : //   IteratorTraits - partial implementation of std::iterator_traits, which
<span class="lineNum">     154 </span>            : //                    is not available in libCstd when compiled with Sun C++.
<span class="lineNum">     155 </span>            : //
<span class="lineNum">     156 </span>            : // Smart pointers:
<span class="lineNum">     157 </span>            : //   scoped_ptr     - as in TR2.
<span class="lineNum">     158 </span>            : //
<span class="lineNum">     159 </span>            : // Regular expressions:
<span class="lineNum">     160 </span>            : //   RE             - a simple regular expression class using the POSIX
<span class="lineNum">     161 </span>            : //                    Extended Regular Expression syntax on UNIX-like
<span class="lineNum">     162 </span>            : //                    platforms, or a reduced regular exception syntax on
<span class="lineNum">     163 </span>            : //                    other platforms, including Windows.
<span class="lineNum">     164 </span>            : //
<span class="lineNum">     165 </span>            : // Logging:
<span class="lineNum">     166 </span>            : //   GTEST_LOG_()   - logs messages at the specified severity level.
<span class="lineNum">     167 </span>            : //   LogToStderr()  - directs all log messages to stderr.
<span class="lineNum">     168 </span>            : //   FlushInfoLog() - flushes informational log messages.
<span class="lineNum">     169 </span>            : //
<span class="lineNum">     170 </span>            : // Stdout and stderr capturing:
<span class="lineNum">     171 </span>            : //   CaptureStdout()     - starts capturing stdout.
<span class="lineNum">     172 </span>            : //   GetCapturedStdout() - stops capturing stdout and returns the captured
<span class="lineNum">     173 </span>            : //                         string.
<span class="lineNum">     174 </span>            : //   CaptureStderr()     - starts capturing stderr.
<span class="lineNum">     175 </span>            : //   GetCapturedStderr() - stops capturing stderr and returns the captured
<span class="lineNum">     176 </span>            : //                         string.
<span class="lineNum">     177 </span>            : //
<span class="lineNum">     178 </span>            : // Integer types:
<span class="lineNum">     179 </span>            : //   TypeWithSize   - maps an integer to a int type.
<span class="lineNum">     180 </span>            : //   Int32, UInt32, Int64, UInt64, TimeInMillis
<span class="lineNum">     181 </span>            : //                  - integers of known sizes.
<span class="lineNum">     182 </span>            : //   BiggestInt     - the biggest signed integer type.
<span class="lineNum">     183 </span>            : //
<span class="lineNum">     184 </span>            : // Command-line utilities:
<span class="lineNum">     185 </span>            : //   GTEST_FLAG()       - references a flag.
<span class="lineNum">     186 </span>            : //   GTEST_DECLARE_*()  - declares a flag.
<span class="lineNum">     187 </span>            : //   GTEST_DEFINE_*()   - defines a flag.
<span class="lineNum">     188 </span>            : //   GetInjectableArgvs() - returns the command line as a vector of strings.
<span class="lineNum">     189 </span>            : //
<span class="lineNum">     190 </span>            : // Environment variable utilities:
<span class="lineNum">     191 </span>            : //   GetEnv()             - gets the value of an environment variable.
<span class="lineNum">     192 </span>            : //   BoolFromGTestEnv()   - parses a bool environment variable.
<span class="lineNum">     193 </span>            : //   Int32FromGTestEnv()  - parses an Int32 environment variable.
<span class="lineNum">     194 </span>            : //   StringFromGTestEnv() - parses a string environment variable.
<span class="lineNum">     195 </span>            : 
<span class="lineNum">     196 </span>            : #include &lt;ctype.h&gt;   // for isspace, etc
<span class="lineNum">     197 </span>            : #include &lt;stddef.h&gt;  // for ptrdiff_t
<span class="lineNum">     198 </span>            : #include &lt;stdlib.h&gt;
<span class="lineNum">     199 </span>            : #include &lt;stdio.h&gt;
<span class="lineNum">     200 </span>            : #include &lt;string.h&gt;
<span class="lineNum">     201 </span>            : #ifndef _WIN32_WCE
<span class="lineNum">     202 </span>            : # include &lt;sys/types.h&gt;
<span class="lineNum">     203 </span>            : # include &lt;sys/stat.h&gt;
<span class="lineNum">     204 </span>            : #endif  // !_WIN32_WCE
<span class="lineNum">     205 </span>            : 
<span class="lineNum">     206 </span>            : #if defined __APPLE__
<span class="lineNum">     207 </span>            : # include &lt;AvailabilityMacros.h&gt;
<span class="lineNum">     208 </span>            : # include &lt;TargetConditionals.h&gt;
<span class="lineNum">     209 </span>            : #endif
<span class="lineNum">     210 </span>            : 
<span class="lineNum">     211 </span>            : #include &lt;iostream&gt;  // NOLINT
<span class="lineNum">     212 </span>            : #include &lt;sstream&gt;  // NOLINT
<span class="lineNum">     213 </span>            : #include &lt;string&gt;  // NOLINT
<span class="lineNum">     214 </span>            : 
<span class="lineNum">     215 </span>            : #define GTEST_DEV_EMAIL_ &quot;googletestframework@@googlegroups.com&quot;
<span class="lineNum">     216 </span>            : #define GTEST_FLAG_PREFIX_ &quot;gtest_&quot;
<span class="lineNum">     217 </span>            : #define GTEST_FLAG_PREFIX_DASH_ &quot;gtest-&quot;
<span class="lineNum">     218 </span>            : #define GTEST_FLAG_PREFIX_UPPER_ &quot;GTEST_&quot;
<span class="lineNum">     219 </span>            : #define GTEST_NAME_ &quot;Google Test&quot;
<span class="lineNum">     220 </span>            : #define GTEST_PROJECT_URL_ &quot;http://code.google.com/p/googletest/&quot;
<span class="lineNum">     221 </span>            : 
<span class="lineNum">     222 </span>            : // Determines the version of gcc that is used to compile this.
<span class="lineNum">     223 </span>            : #ifdef __GNUC__
<span class="lineNum">     224 </span>            : // 40302 means version 4.3.2.
<span class="lineNum">     225 </span>            : # define GTEST_GCC_VER_ \
<span class="lineNum">     226 </span>            :     (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
<span class="lineNum">     227 </span>            : #endif  // __GNUC__
<span class="lineNum">     228 </span>            : 
<span class="lineNum">     229 </span>            : // Determines the platform on which Google Test is compiled.
<span class="lineNum">     230 </span>            : #ifdef __CYGWIN__
<span class="lineNum">     231 </span>            : # define GTEST_OS_CYGWIN 1
<span class="lineNum">     232 </span>            : #elif defined __SYMBIAN32__
<span class="lineNum">     233 </span>            : # define GTEST_OS_SYMBIAN 1
<span class="lineNum">     234 </span>            : #elif defined _WIN32
<span class="lineNum">     235 </span>            : # define GTEST_OS_WINDOWS 1
<span class="lineNum">     236 </span>            : # ifdef _WIN32_WCE
<span class="lineNum">     237 </span>            : #  define GTEST_OS_WINDOWS_MOBILE 1
<span class="lineNum">     238 </span>            : # elif defined(__MINGW__) || defined(__MINGW32__)
<span class="lineNum">     239 </span>            : #  define GTEST_OS_WINDOWS_MINGW 1
<span class="lineNum">     240 </span>            : # else
<span class="lineNum">     241 </span>            : #  define GTEST_OS_WINDOWS_DESKTOP 1
<span class="lineNum">     242 </span>            : # endif  // _WIN32_WCE
<span class="lineNum">     243 </span>            : #elif defined __APPLE__
<span class="lineNum">     244 </span>            : # define GTEST_OS_MAC 1
<span class="lineNum">     245 </span>            : # if TARGET_OS_IPHONE
<span class="lineNum">     246 </span>            : #  define GTEST_OS_IOS 1
<span class="lineNum">     247 </span>            : #  if TARGET_IPHONE_SIMULATOR
<span class="lineNum">     248 </span>            : #   define GTEST_OS_IOS_SIMULATOR 1
<span class="lineNum">     249 </span>            : #  endif
<span class="lineNum">     250 </span>            : # endif
<span class="lineNum">     251 </span>            : #elif defined __linux__
<span class="lineNum">     252 </span>            : # define GTEST_OS_LINUX 1
<span class="lineNum">     253 </span>            : # if defined __ANDROID__
<span class="lineNum">     254 </span>            : #  define GTEST_OS_LINUX_ANDROID 1
<span class="lineNum">     255 </span>            : # endif
<span class="lineNum">     256 </span>            : #elif defined __MVS__
<span class="lineNum">     257 </span>            : # define GTEST_OS_ZOS 1
<span class="lineNum">     258 </span>            : #elif defined(__sun) &amp;&amp; defined(__SVR4)
<span class="lineNum">     259 </span>            : # define GTEST_OS_SOLARIS 1
<span class="lineNum">     260 </span>            : #elif defined(_AIX)
<span class="lineNum">     261 </span>            : # define GTEST_OS_AIX 1
<span class="lineNum">     262 </span>            : #elif defined(__hpux)
<span class="lineNum">     263 </span>            : # define GTEST_OS_HPUX 1
<span class="lineNum">     264 </span>            : #elif defined __native_client__
<span class="lineNum">     265 </span>            : # define GTEST_OS_NACL 1
<span class="lineNum">     266 </span>            : #elif defined __OpenBSD__
<span class="lineNum">     267 </span>            : # define GTEST_OS_OPENBSD 1
<span class="lineNum">     268 </span>            : #elif defined __QNX__
<span class="lineNum">     269 </span>            : # define GTEST_OS_QNX 1
<span class="lineNum">     270 </span>            : #endif  // __CYGWIN__
<span class="lineNum">     271 </span>            : 
<span class="lineNum">     272 </span>            : #ifndef GTEST_LANG_CXX11
<span class="lineNum">     273 </span>            : // gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when
<span class="lineNum">     274 </span>            : // -std={c,gnu}++{0x,11} is passed.  The C++11 standard specifies a
<span class="lineNum">     275 </span>            : // value for __cplusplus, and recent versions of clang, gcc, and
<span class="lineNum">     276 </span>            : // probably other compilers set that too in C++11 mode.
<span class="lineNum">     277 </span>            : # if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus &gt;= 201103L
<span class="lineNum">     278 </span>            : // Compiling in at least C++11 mode.
<span class="lineNum">     279 </span>            : #  define GTEST_LANG_CXX11 1
<span class="lineNum">     280 </span>            : # else
<span class="lineNum">     281 </span>            : #  define GTEST_LANG_CXX11 0
<span class="lineNum">     282 </span>            : # endif
<span class="lineNum">     283 </span>            : #endif
<span class="lineNum">     284 </span>            : 
<span class="lineNum">     285 </span>            : // Brings in definitions for functions used in the testing::internal::posix
<span class="lineNum">     286 </span>            : // namespace (read, write, close, chdir, isatty, stat). We do not currently
<span class="lineNum">     287 </span>            : // use them on Windows Mobile.
<span class="lineNum">     288 </span>            : #if !GTEST_OS_WINDOWS
<span class="lineNum">     289 </span>            : // This assumes that non-Windows OSes provide unistd.h. For OSes where this
<span class="lineNum">     290 </span>            : // is not the case, we need to include headers that provide the functions
<span class="lineNum">     291 </span>            : // mentioned above.
<span class="lineNum">     292 </span>            : # include &lt;unistd.h&gt;
<span class="lineNum">     293 </span>            : # include &lt;strings.h&gt;
<span class="lineNum">     294 </span>            : #elif !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">     295 </span>            : # include &lt;direct.h&gt;
<span class="lineNum">     296 </span>            : # include &lt;io.h&gt;
<span class="lineNum">     297 </span>            : #endif
<span class="lineNum">     298 </span>            : 
<span class="lineNum">     299 </span>            : #if GTEST_OS_LINUX_ANDROID
<span class="lineNum">     300 </span>            : // Used to define __ANDROID_API__ matching the target NDK API level.
<span class="lineNum">     301 </span>            : #  include &lt;android/api-level.h&gt;  // NOLINT
<span class="lineNum">     302 </span>            : #endif
<span class="lineNum">     303 </span>            : 
<span class="lineNum">     304 </span>            : // Defines this to true iff Google Test can use POSIX regular expressions.
<span class="lineNum">     305 </span>            : #ifndef GTEST_HAS_POSIX_RE
<span class="lineNum">     306 </span>            : # if GTEST_OS_LINUX_ANDROID
<span class="lineNum">     307 </span>            : // On Android, &lt;regex.h&gt; is only available starting with Gingerbread.
<span class="lineNum">     308 </span>            : #  define GTEST_HAS_POSIX_RE (__ANDROID_API__ &gt;= 9)
<span class="lineNum">     309 </span>            : # else
<span class="lineNum">     310 </span>            : #  define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
<span class="lineNum">     311 </span>            : # endif
<span class="lineNum">     312 </span>            : #endif
<span class="lineNum">     313 </span>            : 
<span class="lineNum">     314 </span>            : #if GTEST_HAS_POSIX_RE
<span class="lineNum">     315 </span>            : 
<span class="lineNum">     316 </span>            : // On some platforms, &lt;regex.h&gt; needs someone to define size_t, and
<span class="lineNum">     317 </span>            : // won't compile otherwise.  We can #include it here as we already
<span class="lineNum">     318 </span>            : // included &lt;stdlib.h&gt;, which is guaranteed to define size_t through
<span class="lineNum">     319 </span>            : // &lt;stddef.h&gt;.
<span class="lineNum">     320 </span>            : # include &lt;regex.h&gt;  // NOLINT
<span class="lineNum">     321 </span>            : 
<span class="lineNum">     322 </span>            : # define GTEST_USES_POSIX_RE 1
<span class="lineNum">     323 </span>            : 
<span class="lineNum">     324 </span>            : #elif GTEST_OS_WINDOWS
<span class="lineNum">     325 </span>            : 
<span class="lineNum">     326 </span>            : // &lt;regex.h&gt; is not available on Windows.  Use our own simple regex
<span class="lineNum">     327 </span>            : // implementation instead.
<span class="lineNum">     328 </span>            : # define GTEST_USES_SIMPLE_RE 1
<span class="lineNum">     329 </span>            : 
<span class="lineNum">     330 </span>            : #else
<span class="lineNum">     331 </span>            : 
<span class="lineNum">     332 </span>            : // &lt;regex.h&gt; may not be available on this platform.  Use our own
<span class="lineNum">     333 </span>            : // simple regex implementation instead.
<span class="lineNum">     334 </span>            : # define GTEST_USES_SIMPLE_RE 1
<span class="lineNum">     335 </span>            : 
<span class="lineNum">     336 </span>            : #endif  // GTEST_HAS_POSIX_RE
<span class="lineNum">     337 </span>            : 
<span class="lineNum">     338 </span>            : #ifndef GTEST_HAS_EXCEPTIONS
<span class="lineNum">     339 </span>            : // The user didn't tell us whether exceptions are enabled, so we need
<span class="lineNum">     340 </span>            : // to figure it out.
<span class="lineNum">     341 </span>            : # if defined(_MSC_VER) || defined(__BORLANDC__)
<span class="lineNum">     342 </span>            : // MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
<span class="lineNum">     343 </span>            : // macro to enable exceptions, so we'll do the same.
<span class="lineNum">     344 </span>            : // Assumes that exceptions are enabled by default.
<span class="lineNum">     345 </span>            : #  ifndef _HAS_EXCEPTIONS
<span class="lineNum">     346 </span>            : #   define _HAS_EXCEPTIONS 1
<span class="lineNum">     347 </span>            : #  endif  // _HAS_EXCEPTIONS
<span class="lineNum">     348 </span>            : #  define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
<span class="lineNum">     349 </span>            : # elif defined(__GNUC__) &amp;&amp; __EXCEPTIONS
<span class="lineNum">     350 </span>            : // gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
<span class="lineNum">     351 </span>            : #  define GTEST_HAS_EXCEPTIONS 1
<span class="lineNum">     352 </span>            : # elif defined(__SUNPRO_CC)
<span class="lineNum">     353 </span>            : // Sun Pro CC supports exceptions.  However, there is no compile-time way of
<span class="lineNum">     354 </span>            : // detecting whether they are enabled or not.  Therefore, we assume that
<span class="lineNum">     355 </span>            : // they are enabled unless the user tells us otherwise.
<span class="lineNum">     356 </span>            : #  define GTEST_HAS_EXCEPTIONS 1
<span class="lineNum">     357 </span>            : # elif defined(__IBMCPP__) &amp;&amp; __EXCEPTIONS
<span class="lineNum">     358 </span>            : // xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
<span class="lineNum">     359 </span>            : #  define GTEST_HAS_EXCEPTIONS 1
<span class="lineNum">     360 </span>            : # elif defined(__HP_aCC)
<span class="lineNum">     361 </span>            : // Exception handling is in effect by default in HP aCC compiler. It has to
<span class="lineNum">     362 </span>            : // be turned of by +noeh compiler option if desired.
<span class="lineNum">     363 </span>            : #  define GTEST_HAS_EXCEPTIONS 1
<span class="lineNum">     364 </span>            : # else
<span class="lineNum">     365 </span>            : // For other compilers, we assume exceptions are disabled to be
<span class="lineNum">     366 </span>            : // conservative.
<span class="lineNum">     367 </span>            : #  define GTEST_HAS_EXCEPTIONS 0
<span class="lineNum">     368 </span>            : # endif  // defined(_MSC_VER) || defined(__BORLANDC__)
<span class="lineNum">     369 </span>            : #endif  // GTEST_HAS_EXCEPTIONS
<span class="lineNum">     370 </span>            : 
<span class="lineNum">     371 </span>            : #if !defined(GTEST_HAS_STD_STRING)
<span class="lineNum">     372 </span>            : // Even though we don't use this macro any longer, we keep it in case
<span class="lineNum">     373 </span>            : // some clients still depend on it.
<span class="lineNum">     374 </span>            : # define GTEST_HAS_STD_STRING 1
<span class="lineNum">     375 </span>            : #elif !GTEST_HAS_STD_STRING
<span class="lineNum">     376 </span>            : // The user told us that ::std::string isn't available.
<span class="lineNum">     377 </span>            : # error &quot;Google Test cannot be used where ::std::string isn't available.&quot;
<span class="lineNum">     378 </span>            : #endif  // !defined(GTEST_HAS_STD_STRING)
<span class="lineNum">     379 </span>            : 
<span class="lineNum">     380 </span>            : #ifndef GTEST_HAS_GLOBAL_STRING
<span class="lineNum">     381 </span>            : // The user didn't tell us whether ::string is available, so we need
<span class="lineNum">     382 </span>            : // to figure it out.
<span class="lineNum">     383 </span>            : 
<span class="lineNum">     384 </span>            : # define GTEST_HAS_GLOBAL_STRING 0
<span class="lineNum">     385 </span>            : 
<span class="lineNum">     386 </span>            : #endif  // GTEST_HAS_GLOBAL_STRING
<span class="lineNum">     387 </span>            : 
<span class="lineNum">     388 </span>            : #ifndef GTEST_HAS_STD_WSTRING
<span class="lineNum">     389 </span>            : // The user didn't tell us whether ::std::wstring is available, so we need
<span class="lineNum">     390 </span>            : // to figure it out.
<span class="lineNum">     391 </span>            : // TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
<span class="lineNum">     392 </span>            : //   is available.
<span class="lineNum">     393 </span>            : 
<span class="lineNum">     394 </span>            : // Cygwin 1.7 and below doesn't support ::std::wstring.
<span class="lineNum">     395 </span>            : // Solaris' libc++ doesn't support it either.  Android has
<span class="lineNum">     396 </span>            : // no support for it at least as recent as Froyo (2.2).
<span class="lineNum">     397 </span>            : # define GTEST_HAS_STD_WSTRING \
<span class="lineNum">     398 </span>            :     (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
<span class="lineNum">     399 </span>            : 
<span class="lineNum">     400 </span>            : #endif  // GTEST_HAS_STD_WSTRING
<span class="lineNum">     401 </span>            : 
<span class="lineNum">     402 </span>            : #ifndef GTEST_HAS_GLOBAL_WSTRING
<span class="lineNum">     403 </span>            : // The user didn't tell us whether ::wstring is available, so we need
<span class="lineNum">     404 </span>            : // to figure it out.
<span class="lineNum">     405 </span>            : # define GTEST_HAS_GLOBAL_WSTRING \
<span class="lineNum">     406 </span>            :     (GTEST_HAS_STD_WSTRING &amp;&amp; GTEST_HAS_GLOBAL_STRING)
<span class="lineNum">     407 </span>            : #endif  // GTEST_HAS_GLOBAL_WSTRING
<span class="lineNum">     408 </span>            : 
<span class="lineNum">     409 </span>            : // Determines whether RTTI is available.
<span class="lineNum">     410 </span>            : #ifndef GTEST_HAS_RTTI
<span class="lineNum">     411 </span>            : // The user didn't tell us whether RTTI is enabled, so we need to
<span class="lineNum">     412 </span>            : // figure it out.
<span class="lineNum">     413 </span>            : 
<span class="lineNum">     414 </span>            : # ifdef _MSC_VER
<span class="lineNum">     415 </span>            : 
<span class="lineNum">     416 </span>            : #  ifdef _CPPRTTI  // MSVC defines this macro iff RTTI is enabled.
<span class="lineNum">     417 </span>            : #   define GTEST_HAS_RTTI 1
<span class="lineNum">     418 </span>            : #  else
<span class="lineNum">     419 </span>            : #   define GTEST_HAS_RTTI 0
<span class="lineNum">     420 </span>            : #  endif
<span class="lineNum">     421 </span>            : 
<span class="lineNum">     422 </span>            : // Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
<span class="lineNum">     423 </span>            : # elif defined(__GNUC__) &amp;&amp; (GTEST_GCC_VER_ &gt;= 40302)
<span class="lineNum">     424 </span>            : 
<span class="lineNum">     425 </span>            : #  ifdef __GXX_RTTI
<span class="lineNum">     426 </span>            : // When building against STLport with the Android NDK and with
<span class="lineNum">     427 </span>            : // -frtti -fno-exceptions, the build fails at link time with undefined
<span class="lineNum">     428 </span>            : // references to __cxa_bad_typeid. Note sure if STL or toolchain bug,
<span class="lineNum">     429 </span>            : // so disable RTTI when detected.
<span class="lineNum">     430 </span>            : #   if GTEST_OS_LINUX_ANDROID &amp;&amp; defined(_STLPORT_MAJOR) &amp;&amp; \
<span class="lineNum">     431 </span>            :        !defined(__EXCEPTIONS)
<span class="lineNum">     432 </span>            : #    define GTEST_HAS_RTTI 0
<span class="lineNum">     433 </span>            : #   else
<span class="lineNum">     434 </span>            : #    define GTEST_HAS_RTTI 1
<span class="lineNum">     435 </span>            : #   endif  // GTEST_OS_LINUX_ANDROID &amp;&amp; __STLPORT_MAJOR &amp;&amp; !__EXCEPTIONS
<span class="lineNum">     436 </span>            : #  else
<span class="lineNum">     437 </span>            : #   define GTEST_HAS_RTTI 0
<span class="lineNum">     438 </span>            : #  endif  // __GXX_RTTI
<span class="lineNum">     439 </span>            : 
<span class="lineNum">     440 </span>            : // Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends
<span class="lineNum">     441 </span>            : // using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the
<span class="lineNum">     442 </span>            : // first version with C++ support.
<span class="lineNum">     443 </span>            : # elif defined(__clang__)
<span class="lineNum">     444 </span>            : 
<span class="lineNum">     445 </span>            : #  define GTEST_HAS_RTTI __has_feature(cxx_rtti)
<span class="lineNum">     446 </span>            : 
<span class="lineNum">     447 </span>            : // Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if
<span class="lineNum">     448 </span>            : // both the typeid and dynamic_cast features are present.
<span class="lineNum">     449 </span>            : # elif defined(__IBMCPP__) &amp;&amp; (__IBMCPP__ &gt;= 900)
<span class="lineNum">     450 </span>            : 
<span class="lineNum">     451 </span>            : #  ifdef __RTTI_ALL__
<span class="lineNum">     452 </span>            : #   define GTEST_HAS_RTTI 1
<span class="lineNum">     453 </span>            : #  else
<span class="lineNum">     454 </span>            : #   define GTEST_HAS_RTTI 0
<span class="lineNum">     455 </span>            : #  endif
<span class="lineNum">     456 </span>            : 
<span class="lineNum">     457 </span>            : # else
<span class="lineNum">     458 </span>            : 
<span class="lineNum">     459 </span>            : // For all other compilers, we assume RTTI is enabled.
<span class="lineNum">     460 </span>            : #  define GTEST_HAS_RTTI 1
<span class="lineNum">     461 </span>            : 
<span class="lineNum">     462 </span>            : # endif  // _MSC_VER
<span class="lineNum">     463 </span>            : 
<span class="lineNum">     464 </span>            : #endif  // GTEST_HAS_RTTI
<span class="lineNum">     465 </span>            : 
<span class="lineNum">     466 </span>            : // It's this header's responsibility to #include &lt;typeinfo&gt; when RTTI
<span class="lineNum">     467 </span>            : // is enabled.
<span class="lineNum">     468 </span>            : #if GTEST_HAS_RTTI
<span class="lineNum">     469 </span>            : # include &lt;typeinfo&gt;
<span class="lineNum">     470 </span>            : #endif
<span class="lineNum">     471 </span>            : 
<span class="lineNum">     472 </span>            : // Determines whether Google Test can use the pthreads library.
<span class="lineNum">     473 </span>            : #ifndef GTEST_HAS_PTHREAD
<span class="lineNum">     474 </span>            : // The user didn't tell us explicitly, so we assume pthreads support is
<span class="lineNum">     475 </span>            : // available on Linux and Mac.
<span class="lineNum">     476 </span>            : //
<span class="lineNum">     477 </span>            : // To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
<span class="lineNum">     478 </span>            : // to your compiler flags.
<span class="lineNum">     479 </span>            : # define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \
<span class="lineNum">     480 </span>            :     || GTEST_OS_QNX)
<span class="lineNum">     481 </span>            : #endif  // GTEST_HAS_PTHREAD
<span class="lineNum">     482 </span>            : 
<span class="lineNum">     483 </span>            : #if GTEST_HAS_PTHREAD
<span class="lineNum">     484 </span>            : // gtest-port.h guarantees to #include &lt;pthread.h&gt; when GTEST_HAS_PTHREAD is
<span class="lineNum">     485 </span>            : // true.
<span class="lineNum">     486 </span>            : # include &lt;pthread.h&gt;  // NOLINT
<span class="lineNum">     487 </span>            : 
<span class="lineNum">     488 </span>            : // For timespec and nanosleep, used below.
<span class="lineNum">     489 </span>            : # include &lt;time.h&gt;  // NOLINT
<span class="lineNum">     490 </span>            : #endif
<span class="lineNum">     491 </span>            : 
<span class="lineNum">     492 </span>            : // Determines whether Google Test can use tr1/tuple.  You can define
<span class="lineNum">     493 </span>            : // this macro to 0 to prevent Google Test from using tuple (any
<span class="lineNum">     494 </span>            : // feature depending on tuple with be disabled in this mode).
<span class="lineNum">     495 </span>            : #ifndef GTEST_HAS_TR1_TUPLE
<span class="lineNum">     496 </span>            : # if GTEST_OS_LINUX_ANDROID &amp;&amp; defined(_STLPORT_MAJOR)
<span class="lineNum">     497 </span>            : // STLport, provided with the Android NDK, has neither &lt;tr1/tuple&gt; or &lt;tuple&gt;.
<span class="lineNum">     498 </span>            : #  define GTEST_HAS_TR1_TUPLE 0
<span class="lineNum">     499 </span>            : # else
<span class="lineNum">     500 </span>            : // The user didn't tell us not to do it, so we assume it's OK.
<span class="lineNum">     501 </span>            : #  define GTEST_HAS_TR1_TUPLE 1
<span class="lineNum">     502 </span>            : # endif
<span class="lineNum">     503 </span>            : #endif  // GTEST_HAS_TR1_TUPLE
<span class="lineNum">     504 </span>            : 
<span class="lineNum">     505 </span>            : // Determines whether Google Test's own tr1 tuple implementation
<span class="lineNum">     506 </span>            : // should be used.
<span class="lineNum">     507 </span>            : #ifndef GTEST_USE_OWN_TR1_TUPLE
<span class="lineNum">     508 </span>            : // The user didn't tell us, so we need to figure it out.
<span class="lineNum">     509 </span>            : 
<span class="lineNum">     510 </span>            : // We use our own TR1 tuple if we aren't sure the user has an
<span class="lineNum">     511 </span>            : // implementation of it already.  At this time, libstdc++ 4.0.0+ and
<span class="lineNum">     512 </span>            : // MSVC 2010 are the only mainstream standard libraries that come
<span class="lineNum">     513 </span>            : // with a TR1 tuple implementation.  NVIDIA's CUDA NVCC compiler
<span class="lineNum">     514 </span>            : // pretends to be GCC by defining __GNUC__ and friends, but cannot
<span class="lineNum">     515 </span>            : // compile GCC's tuple implementation.  MSVC 2008 (9.0) provides TR1
<span class="lineNum">     516 </span>            : // tuple in a 323 MB Feature Pack download, which we cannot assume the
<span class="lineNum">     517 </span>            : // user has.  QNX's QCC compiler is a modified GCC but it doesn't
<span class="lineNum">     518 </span>            : // support TR1 tuple.  libc++ only provides std::tuple, in C++11 mode,
<span class="lineNum">     519 </span>            : // and it can be used with some compilers that define __GNUC__.
<span class="lineNum">     520 </span>            : # if (defined(__GNUC__) &amp;&amp; !defined(__CUDACC__) &amp;&amp; (GTEST_GCC_VER_ &gt;= 40000) \
<span class="lineNum">     521 </span>            :       &amp;&amp; !GTEST_OS_QNX &amp;&amp; !defined(_LIBCPP_VERSION)) || _MSC_VER &gt;= 1600
<span class="lineNum">     522 </span>            : #  define GTEST_ENV_HAS_TR1_TUPLE_ 1
<span class="lineNum">     523 </span>            : # endif
<span class="lineNum">     524 </span>            : 
<span class="lineNum">     525 </span>            : // C++11 specifies that &lt;tuple&gt; provides std::tuple. Use that if gtest is used
<span class="lineNum">     526 </span>            : // in C++11 mode and libstdc++ isn't very old (binaries targeting OS X 10.6
<span class="lineNum">     527 </span>            : // can build with clang but need to use gcc4.2's libstdc++).
<span class="lineNum">     528 </span>            : # if GTEST_LANG_CXX11 &amp;&amp; (!defined(__GLIBCXX__) || __GLIBCXX__ &gt; 20110325)
<span class="lineNum">     529 </span>            : #  define GTEST_ENV_HAS_STD_TUPLE_ 1
<span class="lineNum">     530 </span>            : # endif
<span class="lineNum">     531 </span>            : 
<span class="lineNum">     532 </span>            : # if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
<span class="lineNum">     533 </span>            : #  define GTEST_USE_OWN_TR1_TUPLE 0
<span class="lineNum">     534 </span>            : # else
<span class="lineNum">     535 </span>            : #  define GTEST_USE_OWN_TR1_TUPLE 1
<span class="lineNum">     536 </span>            : # endif
<span class="lineNum">     537 </span>            : 
<span class="lineNum">     538 </span>            : #endif  // GTEST_USE_OWN_TR1_TUPLE
<span class="lineNum">     539 </span>            : 
<span class="lineNum">     540 </span>            : // To avoid conditional compilation everywhere, we make it
<span class="lineNum">     541 </span>            : // gtest-port.h's responsibility to #include the header implementing
<span class="lineNum">     542 </span>            : // tr1/tuple.
<span class="lineNum">     543 </span>            : #if GTEST_HAS_TR1_TUPLE
<span class="lineNum">     544 </span>            : 
<span class="lineNum">     545 </span>            : # if GTEST_USE_OWN_TR1_TUPLE
<span class="lineNum">     546 </span>            : #  include &quot;gtest/internal/gtest-tuple.h&quot;
<span class="lineNum">     547 </span>            : # elif GTEST_ENV_HAS_STD_TUPLE_
<span class="lineNum">     548 </span>            : #  include &lt;tuple&gt;
<span class="lineNum">     549 </span>            : // C++11 puts its tuple into the ::std namespace rather than
<span class="lineNum">     550 </span>            : // ::std::tr1.  gtest expects tuple to live in ::std::tr1, so put it there.
<span class="lineNum">     551 </span>            : // This causes undefined behavior, but supported compilers react in
<span class="lineNum">     552 </span>            : // the way we intend.
<span class="lineNum">     553 </span>            : namespace std {
<span class="lineNum">     554 </span>            : namespace tr1 {
<span class="lineNum">     555 </span>            : using ::std::get;
<span class="lineNum">     556 </span>            : using ::std::make_tuple;
<span class="lineNum">     557 </span>            : using ::std::tuple;
<span class="lineNum">     558 </span>            : using ::std::tuple_element;
<span class="lineNum">     559 </span>            : using ::std::tuple_size;
<span class="lineNum">     560 </span>            : }
<span class="lineNum">     561 </span>            : }
<span class="lineNum">     562 </span>            : 
<span class="lineNum">     563 </span>            : # elif GTEST_OS_SYMBIAN
<span class="lineNum">     564 </span>            : 
<span class="lineNum">     565 </span>            : // On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
<span class="lineNum">     566 </span>            : // use STLport's tuple implementation, which unfortunately doesn't
<span class="lineNum">     567 </span>            : // work as the copy of STLport distributed with Symbian is incomplete.
<span class="lineNum">     568 </span>            : // By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to
<span class="lineNum">     569 </span>            : // use its own tuple implementation.
<span class="lineNum">     570 </span>            : #  ifdef BOOST_HAS_TR1_TUPLE
<span class="lineNum">     571 </span>            : #   undef BOOST_HAS_TR1_TUPLE
<span class="lineNum">     572 </span>            : #  endif  // BOOST_HAS_TR1_TUPLE
<span class="lineNum">     573 </span>            : 
<span class="lineNum">     574 </span>            : // This prevents &lt;boost/tr1/detail/config.hpp&gt;, which defines
<span class="lineNum">     575 </span>            : // BOOST_HAS_TR1_TUPLE, from being #included by Boost's &lt;tuple&gt;.
<span class="lineNum">     576 </span>            : #  define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED
<span class="lineNum">     577 </span>            : #  include &lt;tuple&gt;
<span class="lineNum">     578 </span>            : 
<span class="lineNum">     579 </span>            : # elif defined(__GNUC__) &amp;&amp; (GTEST_GCC_VER_ &gt;= 40000)
<span class="lineNum">     580 </span>            : // GCC 4.0+ implements tr1/tuple in the &lt;tr1/tuple&gt; header.  This does
<span class="lineNum">     581 </span>            : // not conform to the TR1 spec, which requires the header to be &lt;tuple&gt;.
<span class="lineNum">     582 </span>            : 
<span class="lineNum">     583 </span>            : #  if !GTEST_HAS_RTTI &amp;&amp; GTEST_GCC_VER_ &lt; 40302
<span class="lineNum">     584 </span>            : // Until version 4.3.2, gcc has a bug that causes &lt;tr1/functional&gt;,
<span class="lineNum">     585 </span>            : // which is #included by &lt;tr1/tuple&gt;, to not compile when RTTI is
<span class="lineNum">     586 </span>            : // disabled.  _TR1_FUNCTIONAL is the header guard for
<span class="lineNum">     587 </span>            : // &lt;tr1/functional&gt;.  Hence the following #define is a hack to prevent
<span class="lineNum">     588 </span>            : // &lt;tr1/functional&gt; from being included.
<span class="lineNum">     589 </span>            : #   define _TR1_FUNCTIONAL 1
<span class="lineNum">     590 </span>            : #   include &lt;tr1/tuple&gt;
<span class="lineNum">     591 </span>            : #   undef _TR1_FUNCTIONAL  // Allows the user to #include
<span class="lineNum">     592 </span>            :                         // &lt;tr1/functional&gt; if he chooses to.
<span class="lineNum">     593 </span>            : #  else
<span class="lineNum">     594 </span>            : #   include &lt;tr1/tuple&gt;  // NOLINT
<span class="lineNum">     595 </span>            : #  endif  // !GTEST_HAS_RTTI &amp;&amp; GTEST_GCC_VER_ &lt; 40302
<span class="lineNum">     596 </span>            : 
<span class="lineNum">     597 </span>            : # else
<span class="lineNum">     598 </span>            : // If the compiler is not GCC 4.0+, we assume the user is using a
<span class="lineNum">     599 </span>            : // spec-conforming TR1 implementation.
<span class="lineNum">     600 </span>            : #  include &lt;tuple&gt;  // NOLINT
<span class="lineNum">     601 </span>            : # endif  // GTEST_USE_OWN_TR1_TUPLE
<span class="lineNum">     602 </span>            : 
<span class="lineNum">     603 </span>            : #endif  // GTEST_HAS_TR1_TUPLE
<span class="lineNum">     604 </span>            : 
<span class="lineNum">     605 </span>            : // Determines whether clone(2) is supported.
<span class="lineNum">     606 </span>            : // Usually it will only be available on Linux, excluding
<span class="lineNum">     607 </span>            : // Linux on the Itanium architecture.
<span class="lineNum">     608 </span>            : // Also see http://linux.die.net/man/2/clone.
<span class="lineNum">     609 </span>            : #ifndef GTEST_HAS_CLONE
<span class="lineNum">     610 </span>            : // The user didn't tell us, so we need to figure it out.
<span class="lineNum">     611 </span>            : 
<span class="lineNum">     612 </span>            : # if GTEST_OS_LINUX &amp;&amp; !defined(__ia64__)
<span class="lineNum">     613 </span>            : #  if GTEST_OS_LINUX_ANDROID
<span class="lineNum">     614 </span>            : // On Android, clone() is only available on ARM starting with Gingerbread.
<span class="lineNum">     615 </span>            : #    if defined(__arm__) &amp;&amp; __ANDROID_API__ &gt;= 9
<span class="lineNum">     616 </span>            : #     define GTEST_HAS_CLONE 1
<span class="lineNum">     617 </span>            : #    else
<span class="lineNum">     618 </span>            : #     define GTEST_HAS_CLONE 0
<span class="lineNum">     619 </span>            : #    endif
<span class="lineNum">     620 </span>            : #  else
<span class="lineNum">     621 </span>            : #   define GTEST_HAS_CLONE 1
<span class="lineNum">     622 </span>            : #  endif
<span class="lineNum">     623 </span>            : # else
<span class="lineNum">     624 </span>            : #  define GTEST_HAS_CLONE 0
<span class="lineNum">     625 </span>            : # endif  // GTEST_OS_LINUX &amp;&amp; !defined(__ia64__)
<span class="lineNum">     626 </span>            : 
<span class="lineNum">     627 </span>            : #endif  // GTEST_HAS_CLONE
<span class="lineNum">     628 </span>            : 
<span class="lineNum">     629 </span>            : // Determines whether to support stream redirection. This is used to test
<span class="lineNum">     630 </span>            : // output correctness and to implement death tests.
<span class="lineNum">     631 </span>            : #ifndef GTEST_HAS_STREAM_REDIRECTION
<span class="lineNum">     632 </span>            : // By default, we assume that stream redirection is supported on all
<span class="lineNum">     633 </span>            : // platforms except known mobile ones.
<span class="lineNum">     634 </span>            : # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN
<span class="lineNum">     635 </span>            : #  define GTEST_HAS_STREAM_REDIRECTION 0
<span class="lineNum">     636 </span>            : # else
<span class="lineNum">     637 </span>            : #  define GTEST_HAS_STREAM_REDIRECTION 1
<span class="lineNum">     638 </span>            : # endif  // !GTEST_OS_WINDOWS_MOBILE &amp;&amp; !GTEST_OS_SYMBIAN
<span class="lineNum">     639 </span>            : #endif  // GTEST_HAS_STREAM_REDIRECTION
<span class="lineNum">     640 </span>            : 
<span class="lineNum">     641 </span>            : // Determines whether to support death tests.
<span class="lineNum">     642 </span>            : // Google Test does not support death tests for VC 7.1 and earlier as
<span class="lineNum">     643 </span>            : // abort() in a VC 7.1 application compiled as GUI in debug config
<span class="lineNum">     644 </span>            : // pops up a dialog window that cannot be suppressed programmatically.
<span class="lineNum">     645 </span>            : #if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
<span class="lineNum">     646 </span>            :      (GTEST_OS_MAC &amp;&amp; !GTEST_OS_IOS) || GTEST_OS_IOS_SIMULATOR || \
<span class="lineNum">     647 </span>            :      (GTEST_OS_WINDOWS_DESKTOP &amp;&amp; _MSC_VER &gt;= 1400) || \
<span class="lineNum">     648 </span>            :      GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
<span class="lineNum">     649 </span>            :      GTEST_OS_OPENBSD || GTEST_OS_QNX)
<span class="lineNum">     650 </span>            : # define GTEST_HAS_DEATH_TEST 1
<span class="lineNum">     651 </span>            : # include &lt;vector&gt;  // NOLINT
<span class="lineNum">     652 </span>            : #endif
<span class="lineNum">     653 </span>            : 
<span class="lineNum">     654 </span>            : // We don't support MSVC 7.1 with exceptions disabled now.  Therefore
<span class="lineNum">     655 </span>            : // all the compilers we care about are adequate for supporting
<span class="lineNum">     656 </span>            : // value-parameterized tests.
<span class="lineNum">     657 </span>            : #define GTEST_HAS_PARAM_TEST 1
<span class="lineNum">     658 </span>            : 
<span class="lineNum">     659 </span>            : // Determines whether to support type-driven tests.
<span class="lineNum">     660 </span>            : 
<span class="lineNum">     661 </span>            : // Typed tests need &lt;typeinfo&gt; and variadic macros, which GCC, VC++ 8.0,
<span class="lineNum">     662 </span>            : // Sun Pro CC, IBM Visual Age, and HP aCC support.
<span class="lineNum">     663 </span>            : #if defined(__GNUC__) || (_MSC_VER &gt;= 1400) || defined(__SUNPRO_CC) || \
<span class="lineNum">     664 </span>            :     defined(__IBMCPP__) || defined(__HP_aCC)
<span class="lineNum">     665 </span>            : # define GTEST_HAS_TYPED_TEST 1
<span class="lineNum">     666 </span>            : # define GTEST_HAS_TYPED_TEST_P 1
<span class="lineNum">     667 </span>            : #endif
<span class="lineNum">     668 </span>            : 
<span class="lineNum">     669 </span>            : // Determines whether to support Combine(). This only makes sense when
<span class="lineNum">     670 </span>            : // value-parameterized tests are enabled.  The implementation doesn't
<span class="lineNum">     671 </span>            : // work on Sun Studio since it doesn't understand templated conversion
<span class="lineNum">     672 </span>            : // operators.
<span class="lineNum">     673 </span>            : #if GTEST_HAS_PARAM_TEST &amp;&amp; GTEST_HAS_TR1_TUPLE &amp;&amp; !defined(__SUNPRO_CC)
<span class="lineNum">     674 </span>            : # define GTEST_HAS_COMBINE 1
<span class="lineNum">     675 </span>            : #endif
<span class="lineNum">     676 </span>            : 
<span class="lineNum">     677 </span>            : // Determines whether the system compiler uses UTF-16 for encoding wide strings.
<span class="lineNum">     678 </span>            : #define GTEST_WIDE_STRING_USES_UTF16_ \
<span class="lineNum">     679 </span>            :     (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
<span class="lineNum">     680 </span>            : 
<span class="lineNum">     681 </span>            : // Determines whether test results can be streamed to a socket.
<span class="lineNum">     682 </span>            : #if GTEST_OS_LINUX
<span class="lineNum">     683 </span>            : # define GTEST_CAN_STREAM_RESULTS_ 1
<span class="lineNum">     684 </span>            : #endif
<span class="lineNum">     685 </span>            : 
<span class="lineNum">     686 </span>            : // Defines some utility macros.
<span class="lineNum">     687 </span>            : 
<span class="lineNum">     688 </span>            : // The GNU compiler emits a warning if nested &quot;if&quot; statements are followed by
<span class="lineNum">     689 </span>            : // an &quot;else&quot; statement and braces are not used to explicitly disambiguate the
<span class="lineNum">     690 </span>            : // &quot;else&quot; binding.  This leads to problems with code like:
<span class="lineNum">     691 </span>            : //
<span class="lineNum">     692 </span>            : //   if (gate)
<span class="lineNum">     693 </span>            : //     ASSERT_*(condition) &lt;&lt; &quot;Some message&quot;;
<span class="lineNum">     694 </span>            : //
<span class="lineNum">     695 </span>            : // The &quot;switch (0) case 0:&quot; idiom is used to suppress this.
<span class="lineNum">     696 </span>            : #ifdef __INTEL_COMPILER
<span class="lineNum">     697 </span>            : # define GTEST_AMBIGUOUS_ELSE_BLOCKER_
<span class="lineNum">     698 </span>            : #else
<span class="lineNum">     699 </span>            : # define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT
<span class="lineNum">     700 </span>            : #endif
<span class="lineNum">     701 </span>            : 
<span class="lineNum">     702 </span>            : // Use this annotation at the end of a struct/class definition to
<span class="lineNum">     703 </span>            : // prevent the compiler from optimizing away instances that are never
<span class="lineNum">     704 </span>            : // used.  This is useful when all interesting logic happens inside the
<span class="lineNum">     705 </span>            : // c'tor and / or d'tor.  Example:
<span class="lineNum">     706 </span>            : //
<span class="lineNum">     707 </span>            : //   struct Foo {
<span class="lineNum">     708 </span>            : //     Foo() { ... }
<span class="lineNum">     709 </span>            : //   } GTEST_ATTRIBUTE_UNUSED_;
<span class="lineNum">     710 </span>            : //
<span class="lineNum">     711 </span>            : // Also use it after a variable or parameter declaration to tell the
<span class="lineNum">     712 </span>            : // compiler the variable/parameter does not have to be used.
<span class="lineNum">     713 </span>            : #if defined(__GNUC__) &amp;&amp; !defined(COMPILER_ICC)
<span class="lineNum">     714 </span>            : # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
<span class="lineNum">     715 </span>            : #else
<span class="lineNum">     716 </span>            : # define GTEST_ATTRIBUTE_UNUSED_
<span class="lineNum">     717 </span>            : #endif
<span class="lineNum">     718 </span>            : 
<span class="lineNum">     719 </span>            : // A macro to disallow operator=
<span class="lineNum">     720 </span>            : // This should be used in the private: declarations for a class.
<span class="lineNum">     721 </span>            : #define GTEST_DISALLOW_ASSIGN_(type)\
<span class="lineNum">     722 </span>            :   void operator=(type const &amp;)
<span class="lineNum">     723 </span>            : 
<span class="lineNum">     724 </span>            : // A macro to disallow copy constructor and operator=
<span class="lineNum">     725 </span>            : // This should be used in the private: declarations for a class.
<span class="lineNum">     726 </span>            : #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
<span class="lineNum">     727 </span>            :   type(type const &amp;);\
<span class="lineNum">     728 </span>            :   GTEST_DISALLOW_ASSIGN_(type)
<span class="lineNum">     729 </span>            : 
<span class="lineNum">     730 </span>            : // Tell the compiler to warn about unused return values for functions declared
<span class="lineNum">     731 </span>            : // with this macro.  The macro should be used on function declarations
<span class="lineNum">     732 </span>            : // following the argument list:
<span class="lineNum">     733 </span>            : //
<span class="lineNum">     734 </span>            : //   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
<span class="lineNum">     735 </span>            : #if defined(__GNUC__) &amp;&amp; (GTEST_GCC_VER_ &gt;= 30400) &amp;&amp; !defined(COMPILER_ICC)
<span class="lineNum">     736 </span>            : # define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
<span class="lineNum">     737 </span>            : #else
<span class="lineNum">     738 </span>            : # define GTEST_MUST_USE_RESULT_
<span class="lineNum">     739 </span>            : #endif  // __GNUC__ &amp;&amp; (GTEST_GCC_VER_ &gt;= 30400) &amp;&amp; !COMPILER_ICC
<span class="lineNum">     740 </span>            : 
<span class="lineNum">     741 </span>            : // Determine whether the compiler supports Microsoft's Structured Exception
<span class="lineNum">     742 </span>            : // Handling.  This is supported by several Windows compilers but generally
<span class="lineNum">     743 </span>            : // does not exist on any other system.
<span class="lineNum">     744 </span>            : #ifndef GTEST_HAS_SEH
<span class="lineNum">     745 </span>            : // The user didn't tell us, so we need to figure it out.
<span class="lineNum">     746 </span>            : 
<span class="lineNum">     747 </span>            : # if defined(_MSC_VER) || defined(__BORLANDC__)
<span class="lineNum">     748 </span>            : // These two compilers are known to support SEH.
<span class="lineNum">     749 </span>            : #  define GTEST_HAS_SEH 1
<span class="lineNum">     750 </span>            : # else
<span class="lineNum">     751 </span>            : // Assume no SEH.
<span class="lineNum">     752 </span>            : #  define GTEST_HAS_SEH 0
<span class="lineNum">     753 </span>            : # endif
<span class="lineNum">     754 </span>            : 
<span class="lineNum">     755 </span>            : #endif  // GTEST_HAS_SEH
<span class="lineNum">     756 </span>            : 
<span class="lineNum">     757 </span>            : #ifdef _MSC_VER
<span class="lineNum">     758 </span>            : 
<span class="lineNum">     759 </span>            : # if GTEST_LINKED_AS_SHARED_LIBRARY
<span class="lineNum">     760 </span>            : #  define GTEST_API_ __declspec(dllimport)
<span class="lineNum">     761 </span>            : # elif GTEST_CREATE_SHARED_LIBRARY
<span class="lineNum">     762 </span>            : #  define GTEST_API_ __declspec(dllexport)
<span class="lineNum">     763 </span>            : # endif
<span class="lineNum">     764 </span>            : 
<span class="lineNum">     765 </span>            : #endif  // _MSC_VER
<span class="lineNum">     766 </span>            : 
<span class="lineNum">     767 </span>            : #ifndef GTEST_API_
<span class="lineNum">     768 </span>            : # define GTEST_API_
<span class="lineNum">     769 </span>            : #endif
<span class="lineNum">     770 </span>            : 
<span class="lineNum">     771 </span>            : #ifdef __GNUC__
<span class="lineNum">     772 </span>            : // Ask the compiler to never inline a given function.
<span class="lineNum">     773 </span>            : # define GTEST_NO_INLINE_ __attribute__((noinline))
<span class="lineNum">     774 </span>            : #else
<span class="lineNum">     775 </span>            : # define GTEST_NO_INLINE_
<span class="lineNum">     776 </span>            : #endif
<span class="lineNum">     777 </span>            : 
<span class="lineNum">     778 </span>            : // _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
<span class="lineNum">     779 </span>            : #if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
<span class="lineNum">     780 </span>            : # define GTEST_HAS_CXXABI_H_ 1
<span class="lineNum">     781 </span>            : #else
<span class="lineNum">     782 </span>            : # define GTEST_HAS_CXXABI_H_ 0
<span class="lineNum">     783 </span>            : #endif
<span class="lineNum">     784 </span>            : 
<span class="lineNum">     785 </span>            : namespace testing {
<span class="lineNum">     786 </span>            : 
<span class="lineNum">     787 </span>            : class Message;
<span class="lineNum">     788 </span>            : 
<span class="lineNum">     789 </span>            : namespace internal {
<span class="lineNum">     790 </span>            : 
<span class="lineNum">     791 </span>            : // A secret type that Google Test users don't know about.  It has no
<span class="lineNum">     792 </span>            : // definition on purpose.  Therefore it's impossible to create a
<span class="lineNum">     793 </span>            : // Secret object, which is what we want.
<span class="lineNum">     794 </span>            : class Secret;
<span class="lineNum">     795 </span>            : 
<span class="lineNum">     796 </span>            : // The GTEST_COMPILE_ASSERT_ macro can be used to verify that a compile time
<span class="lineNum">     797 </span>            : // expression is true. For example, you could use it to verify the
<span class="lineNum">     798 </span>            : // size of a static array:
<span class="lineNum">     799 </span>            : //
<span class="lineNum">     800 </span>            : //   GTEST_COMPILE_ASSERT_(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,
<span class="lineNum">     801 </span>            : //                         content_type_names_incorrect_size);
<span class="lineNum">     802 </span>            : //
<span class="lineNum">     803 </span>            : // or to make sure a struct is smaller than a certain size:
<span class="lineNum">     804 </span>            : //
<span class="lineNum">     805 </span>            : //   GTEST_COMPILE_ASSERT_(sizeof(foo) &lt; 128, foo_too_large);
<span class="lineNum">     806 </span>            : //
<span class="lineNum">     807 </span>            : // The second argument to the macro is the name of the variable. If
<span class="lineNum">     808 </span>            : // the expression is false, most compilers will issue a warning/error
<span class="lineNum">     809 </span>            : // containing the name of the variable.
<span class="lineNum">     810 </span>            : 
<span class="lineNum">     811 </span>            : template &lt;bool&gt;
<span class="lineNum">     812 </span>            : struct CompileAssert {
<span class="lineNum">     813 </span>            : };
<span class="lineNum">     814 </span>            : 
<span class="lineNum">     815 </span>            : #define GTEST_COMPILE_ASSERT_(expr, msg) \
<span class="lineNum">     816 </span>            :   typedef ::testing::internal::CompileAssert&lt;(static_cast&lt;bool&gt;(expr))&gt; \
<span class="lineNum">     817 </span>            :       msg[static_cast&lt;bool&gt;(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_
<span class="lineNum">     818 </span>            : 
<span class="lineNum">     819 </span>            : // Implementation details of GTEST_COMPILE_ASSERT_:
<span class="lineNum">     820 </span>            : //
<span class="lineNum">     821 </span>            : // - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1
<span class="lineNum">     822 </span>            : //   elements (and thus is invalid) when the expression is false.
<span class="lineNum">     823 </span>            : //
<span class="lineNum">     824 </span>            : // - The simpler definition
<span class="lineNum">     825 </span>            : //
<span class="lineNum">     826 </span>            : //    #define GTEST_COMPILE_ASSERT_(expr, msg) typedef char msg[(expr) ? 1 : -1]
<span class="lineNum">     827 </span>            : //
<span class="lineNum">     828 </span>            : //   does not work, as gcc supports variable-length arrays whose sizes
<span class="lineNum">     829 </span>            : //   are determined at run-time (this is gcc's extension and not part
<span class="lineNum">     830 </span>            : //   of the C++ standard).  As a result, gcc fails to reject the
<span class="lineNum">     831 </span>            : //   following code with the simple definition:
<span class="lineNum">     832 </span>            : //
<span class="lineNum">     833 </span>            : //     int foo;
<span class="lineNum">     834 </span>            : //     GTEST_COMPILE_ASSERT_(foo, msg); // not supposed to compile as foo is
<span class="lineNum">     835 </span>            : //                                      // not a compile-time constant.
<span class="lineNum">     836 </span>            : //
<span class="lineNum">     837 </span>            : // - By using the type CompileAssert&lt;(bool(expr))&gt;, we ensures that
<span class="lineNum">     838 </span>            : //   expr is a compile-time constant.  (Template arguments must be
<span class="lineNum">     839 </span>            : //   determined at compile-time.)
<span class="lineNum">     840 </span>            : //
<span class="lineNum">     841 </span>            : // - The outter parentheses in CompileAssert&lt;(bool(expr))&gt; are necessary
<span class="lineNum">     842 </span>            : //   to work around a bug in gcc 3.4.4 and 4.0.1.  If we had written
<span class="lineNum">     843 </span>            : //
<span class="lineNum">     844 </span>            : //     CompileAssert&lt;bool(expr)&gt;
<span class="lineNum">     845 </span>            : //
<span class="lineNum">     846 </span>            : //   instead, these compilers will refuse to compile
<span class="lineNum">     847 </span>            : //
<span class="lineNum">     848 </span>            : //     GTEST_COMPILE_ASSERT_(5 &gt; 0, some_message);
<span class="lineNum">     849 </span>            : //
<span class="lineNum">     850 </span>            : //   (They seem to think the &quot;&gt;&quot; in &quot;5 &gt; 0&quot; marks the end of the
<span class="lineNum">     851 </span>            : //   template argument list.)
<span class="lineNum">     852 </span>            : //
<span class="lineNum">     853 </span>            : // - The array size is (bool(expr) ? 1 : -1), instead of simply
<span class="lineNum">     854 </span>            : //
<span class="lineNum">     855 </span>            : //     ((expr) ? 1 : -1).
<span class="lineNum">     856 </span>            : //
<span class="lineNum">     857 </span>            : //   This is to avoid running into a bug in MS VC 7.1, which
<span class="lineNum">     858 </span>            : //   causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
<span class="lineNum">     859 </span>            : 
<span class="lineNum">     860 </span>            : // StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.
<span class="lineNum">     861 </span>            : //
<span class="lineNum">     862 </span>            : // This template is declared, but intentionally undefined.
<span class="lineNum">     863 </span>            : template &lt;typename T1, typename T2&gt;
<span class="lineNum">     864 </span>            : struct StaticAssertTypeEqHelper;
<span class="lineNum">     865 </span>            : 
<span class="lineNum">     866 </span>            : template &lt;typename T&gt;
<span class="lineNum">     867 </span>            : struct StaticAssertTypeEqHelper&lt;T, T&gt; {};
<span class="lineNum">     868 </span>            : 
<span class="lineNum">     869 </span>            : #if GTEST_HAS_GLOBAL_STRING
<span class="lineNum">     870 </span>            : typedef ::string string;
<span class="lineNum">     871 </span>            : #else
<span class="lineNum">     872 </span>            : typedef ::std::string string;
<span class="lineNum">     873 </span>            : #endif  // GTEST_HAS_GLOBAL_STRING
<span class="lineNum">     874 </span>            : 
<span class="lineNum">     875 </span>            : #if GTEST_HAS_GLOBAL_WSTRING
<span class="lineNum">     876 </span>            : typedef ::wstring wstring;
<span class="lineNum">     877 </span>            : #elif GTEST_HAS_STD_WSTRING
<span class="lineNum">     878 </span>            : typedef ::std::wstring wstring;
<span class="lineNum">     879 </span>            : #endif  // GTEST_HAS_GLOBAL_WSTRING
<span class="lineNum">     880 </span>            : 
<span class="lineNum">     881 </span>            : // A helper for suppressing warnings on constant condition.  It just
<span class="lineNum">     882 </span>            : // returns 'condition'.
<span class="lineNum">     883 </span>            : GTEST_API_ bool IsTrue(bool condition);
<span class="lineNum">     884 </span>            : 
<span class="lineNum">     885 </span>            : // Defines scoped_ptr.
<span class="lineNum">     886 </span>            : 
<span class="lineNum">     887 </span>            : // This implementation of scoped_ptr is PARTIAL - it only contains
<span class="lineNum">     888 </span>            : // enough stuff to satisfy Google Test's need.
<span class="lineNum">     889 </span>            : template &lt;typename T&gt;
<span class="lineNum">     890 </span>            : class scoped_ptr {
<span class="lineNum">     891 </span>            :  public:
<a name="892"><span class="lineNum">     892 </span>            :   typedef T element_type;</a>
<a name="893"><span class="lineNum">     893 </span>            : </a>
<span class="lineNum">     894 </span><span class="lineNoCov">          0 :   explicit scoped_ptr(T* p = NULL) : ptr_(p) {}</span>
<a name="895"><span class="lineNum">     895 </span><span class="lineNoCov">          0 :   ~scoped_ptr() { reset(); }</span></a>
<a name="896"><span class="lineNum">     896 </span>            : </a>
<a name="897"><span class="lineNum">     897 </span><span class="lineNoCov">          0 :   T&amp; operator*() const { return *ptr_; }</span></a>
<span class="lineNum">     898 </span><span class="lineNoCov">          0 :   T* operator-&gt;() const { return ptr_; }</span>
<span class="lineNum">     899 </span><span class="lineNoCov">          0 :   T* get() const { return ptr_; }</span>
<span class="lineNum">     900 </span>            : 
<span class="lineNum">     901 </span>            :   T* release() {
<span class="lineNum">     902 </span>            :     T* const ptr = ptr_;
<span class="lineNum">     903 </span>            :     ptr_ = NULL;
<span class="lineNum">     904 </span>            :     return ptr;
<a name="905"><span class="lineNum">     905 </span>            :   }</a>
<span class="lineNum">     906 </span>            : 
<span class="lineNum">     907 </span><span class="lineNoCov">          0 :   void reset(T* p = NULL) {</span>
<span class="lineNum">     908 </span><span class="lineNoCov">          0 :     if (p != ptr_) {</span>
<span class="lineNum">     909 </span><span class="lineNoCov">          0 :       if (IsTrue(sizeof(T) &gt; 0)) {  // Makes sure T is a complete type.</span>
<span class="lineNum">     910 </span><span class="lineNoCov">          0 :         delete ptr_;</span>
<span class="lineNum">     911 </span>            :       }
<span class="lineNum">     912 </span><span class="lineNoCov">          0 :       ptr_ = p;</span>
<span class="lineNum">     913 </span>            :     }
<span class="lineNum">     914 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">     915 </span>            : 
<span class="lineNum">     916 </span>            :  private:
<span class="lineNum">     917 </span>            :   T* ptr_;
<span class="lineNum">     918 </span>            : 
<span class="lineNum">     919 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
<span class="lineNum">     920 </span>            : };
<span class="lineNum">     921 </span>            : 
<span class="lineNum">     922 </span>            : // Defines RE.
<span class="lineNum">     923 </span>            : 
<span class="lineNum">     924 </span>            : // A simple C++ wrapper for &lt;regex.h&gt;.  It uses the POSIX Extended
<span class="lineNum">     925 </span>            : // Regular Expression syntax.
<span class="lineNum">     926 </span>            : class GTEST_API_ RE {
<span class="lineNum">     927 </span>            :  public:
<span class="lineNum">     928 </span>            :   // A copy constructor is required by the Standard to initialize object
<span class="lineNum">     929 </span>            :   // references from r-values.
<span class="lineNum">     930 </span>            :   RE(const RE&amp; other) { Init(other.pattern()); }
<span class="lineNum">     931 </span>            : 
<span class="lineNum">     932 </span>            :   // Constructs an RE from a string.
<span class="lineNum">     933 </span>            :   RE(const ::std::string&amp; regex) { Init(regex.c_str()); }  // NOLINT
<span class="lineNum">     934 </span>            : 
<span class="lineNum">     935 </span>            : #if GTEST_HAS_GLOBAL_STRING
<span class="lineNum">     936 </span>            : 
<span class="lineNum">     937 </span>            :   RE(const ::string&amp; regex) { Init(regex.c_str()); }  // NOLINT
<span class="lineNum">     938 </span>            : 
<span class="lineNum">     939 </span>            : #endif  // GTEST_HAS_GLOBAL_STRING
<span class="lineNum">     940 </span>            : 
<span class="lineNum">     941 </span>            :   RE(const char* regex) { Init(regex); }  // NOLINT
<span class="lineNum">     942 </span>            :   ~RE();
<a name="943"><span class="lineNum">     943 </span>            : </a>
<span class="lineNum">     944 </span>            :   // Returns the string representation of the regex.
<span class="lineNum">     945 </span><span class="lineNoCov">          0 :   const char* pattern() const { return pattern_; }</span>
<span class="lineNum">     946 </span>            : 
<span class="lineNum">     947 </span>            :   // FullMatch(str, re) returns true iff regular expression re matches
<span class="lineNum">     948 </span>            :   // the entire str.
<span class="lineNum">     949 </span>            :   // PartialMatch(str, re) returns true iff regular expression re
<span class="lineNum">     950 </span>            :   // matches a substring of str (including str itself).
<span class="lineNum">     951 </span>            :   //
<span class="lineNum">     952 </span>            :   // TODO(wan@google.com): make FullMatch() and PartialMatch() work
<span class="lineNum">     953 </span>            :   // when str contains NUL characters.
<span class="lineNum">     954 </span>            :   static bool FullMatch(const ::std::string&amp; str, const RE&amp; re) {
<span class="lineNum">     955 </span>            :     return FullMatch(str.c_str(), re);
<span class="lineNum">     956 </span>            :   }
<span class="lineNum">     957 </span>            :   static bool PartialMatch(const ::std::string&amp; str, const RE&amp; re) {
<span class="lineNum">     958 </span>            :     return PartialMatch(str.c_str(), re);
<span class="lineNum">     959 </span>            :   }
<span class="lineNum">     960 </span>            : 
<span class="lineNum">     961 </span>            : #if GTEST_HAS_GLOBAL_STRING
<span class="lineNum">     962 </span>            : 
<span class="lineNum">     963 </span>            :   static bool FullMatch(const ::string&amp; str, const RE&amp; re) {
<span class="lineNum">     964 </span>            :     return FullMatch(str.c_str(), re);
<span class="lineNum">     965 </span>            :   }
<span class="lineNum">     966 </span>            :   static bool PartialMatch(const ::string&amp; str, const RE&amp; re) {
<span class="lineNum">     967 </span>            :     return PartialMatch(str.c_str(), re);
<span class="lineNum">     968 </span>            :   }
<span class="lineNum">     969 </span>            : 
<span class="lineNum">     970 </span>            : #endif  // GTEST_HAS_GLOBAL_STRING
<span class="lineNum">     971 </span>            : 
<span class="lineNum">     972 </span>            :   static bool FullMatch(const char* str, const RE&amp; re);
<span class="lineNum">     973 </span>            :   static bool PartialMatch(const char* str, const RE&amp; re);
<span class="lineNum">     974 </span>            : 
<span class="lineNum">     975 </span>            :  private:
<span class="lineNum">     976 </span>            :   void Init(const char* regex);
<span class="lineNum">     977 </span>            : 
<span class="lineNum">     978 </span>            :   // We use a const char* instead of an std::string, as Google Test used to be
<span class="lineNum">     979 </span>            :   // used where std::string is not available.  TODO(wan@google.com): change to
<span class="lineNum">     980 </span>            :   // std::string.
<span class="lineNum">     981 </span>            :   const char* pattern_;
<span class="lineNum">     982 </span>            :   bool is_valid_;
<span class="lineNum">     983 </span>            : 
<span class="lineNum">     984 </span>            : #if GTEST_USES_POSIX_RE
<span class="lineNum">     985 </span>            : 
<span class="lineNum">     986 </span>            :   regex_t full_regex_;     // For FullMatch().
<span class="lineNum">     987 </span>            :   regex_t partial_regex_;  // For PartialMatch().
<span class="lineNum">     988 </span>            : 
<span class="lineNum">     989 </span>            : #else  // GTEST_USES_SIMPLE_RE
<span class="lineNum">     990 </span>            : 
<span class="lineNum">     991 </span>            :   const char* full_pattern_;  // For FullMatch();
<span class="lineNum">     992 </span>            : 
<span class="lineNum">     993 </span>            : #endif
<span class="lineNum">     994 </span>            : 
<span class="lineNum">     995 </span>            :   GTEST_DISALLOW_ASSIGN_(RE);
<span class="lineNum">     996 </span>            : };
<span class="lineNum">     997 </span>            : 
<span class="lineNum">     998 </span>            : // Formats a source file path and a line number as they would appear
<span class="lineNum">     999 </span>            : // in an error message from the compiler used to compile this code.
<span class="lineNum">    1000 </span>            : GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
<span class="lineNum">    1001 </span>            : 
<span class="lineNum">    1002 </span>            : // Formats a file location for compiler-independent XML output.
<span class="lineNum">    1003 </span>            : // Although this function is not platform dependent, we put it next to
<span class="lineNum">    1004 </span>            : // FormatFileLocation in order to contrast the two functions.
<span class="lineNum">    1005 </span>            : GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,
<span class="lineNum">    1006 </span>            :                                                                int line);
<span class="lineNum">    1007 </span>            : 
<span class="lineNum">    1008 </span>            : // Defines logging utilities:
<span class="lineNum">    1009 </span>            : //   GTEST_LOG_(severity) - logs messages at the specified severity level. The
<span class="lineNum">    1010 </span>            : //                          message itself is streamed into the macro.
<span class="lineNum">    1011 </span>            : //   LogToStderr()  - directs all log messages to stderr.
<span class="lineNum">    1012 </span>            : //   FlushInfoLog() - flushes informational log messages.
<span class="lineNum">    1013 </span>            : 
<span class="lineNum">    1014 </span>            : enum GTestLogSeverity {
<span class="lineNum">    1015 </span>            :   GTEST_INFO,
<span class="lineNum">    1016 </span>            :   GTEST_WARNING,
<span class="lineNum">    1017 </span>            :   GTEST_ERROR,
<span class="lineNum">    1018 </span>            :   GTEST_FATAL
<span class="lineNum">    1019 </span>            : };
<span class="lineNum">    1020 </span>            : 
<span class="lineNum">    1021 </span>            : // Formats log entry severity, provides a stream object for streaming the
<span class="lineNum">    1022 </span>            : // log message, and terminates the message with a newline when going out of
<span class="lineNum">    1023 </span>            : // scope.
<span class="lineNum">    1024 </span>            : class GTEST_API_ GTestLog {
<span class="lineNum">    1025 </span>            :  public:
<span class="lineNum">    1026 </span>            :   GTestLog(GTestLogSeverity severity, const char* file, int line);
<span class="lineNum">    1027 </span>            : 
<span class="lineNum">    1028 </span>            :   // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
<a name="1029"><span class="lineNum">    1029 </span>            :   ~GTestLog();</a>
<span class="lineNum">    1030 </span>            : 
<span class="lineNum">    1031 </span><span class="lineNoCov">          0 :   ::std::ostream&amp; GetStream() { return ::std::cerr; }</span>
<span class="lineNum">    1032 </span>            : 
<span class="lineNum">    1033 </span>            :  private:
<span class="lineNum">    1034 </span>            :   const GTestLogSeverity severity_;
<span class="lineNum">    1035 </span>            : 
<span class="lineNum">    1036 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
<span class="lineNum">    1037 </span>            : };
<span class="lineNum">    1038 </span>            : 
<span class="lineNum">    1039 </span>            : #define GTEST_LOG_(severity) \
<span class="lineNum">    1040 </span>            :     ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
<a name="1041"><span class="lineNum">    1041 </span>            :                                   __FILE__, __LINE__).GetStream()</a>
<a name="1042"><span class="lineNum">    1042 </span>            : </a>
<span class="lineNum">    1043 </span><span class="lineNoCov">          0 : inline void LogToStderr() {}</span>
<span class="lineNum">    1044 </span><span class="lineNoCov">          0 : inline void FlushInfoLog() { fflush(NULL); }</span>
<span class="lineNum">    1045 </span>            : 
<span class="lineNum">    1046 </span>            : // INTERNAL IMPLEMENTATION - DO NOT USE.
<span class="lineNum">    1047 </span>            : //
<span class="lineNum">    1048 </span>            : // GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
<span class="lineNum">    1049 </span>            : // is not satisfied.
<span class="lineNum">    1050 </span>            : //  Synopsys:
<span class="lineNum">    1051 </span>            : //    GTEST_CHECK_(boolean_condition);
<span class="lineNum">    1052 </span>            : //     or
<span class="lineNum">    1053 </span>            : //    GTEST_CHECK_(boolean_condition) &lt;&lt; &quot;Additional message&quot;;
<span class="lineNum">    1054 </span>            : //
<span class="lineNum">    1055 </span>            : //    This checks the condition and if the condition is not satisfied
<span class="lineNum">    1056 </span>            : //    it prints message about the condition violation, including the
<span class="lineNum">    1057 </span>            : //    condition itself, plus additional message streamed into it, if any,
<span class="lineNum">    1058 </span>            : //    and then it aborts the program. It aborts the program irrespective of
<span class="lineNum">    1059 </span>            : //    whether it is built in the debug mode or not.
<span class="lineNum">    1060 </span>            : #define GTEST_CHECK_(condition) \
<span class="lineNum">    1061 </span>            :     GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
<span class="lineNum">    1062 </span>            :     if (::testing::internal::IsTrue(condition)) \
<span class="lineNum">    1063 </span>            :       ; \
<span class="lineNum">    1064 </span>            :     else \
<span class="lineNum">    1065 </span>            :       GTEST_LOG_(FATAL) &lt;&lt; &quot;Condition &quot; #condition &quot; failed. &quot;
<span class="lineNum">    1066 </span>            : 
<span class="lineNum">    1067 </span>            : // An all-mode assert to verify that the given POSIX-style function
<span class="lineNum">    1068 </span>            : // call returns 0 (indicating success).  Known limitation: this
<span class="lineNum">    1069 </span>            : // doesn't expand to a balanced 'if' statement, so enclose the macro
<span class="lineNum">    1070 </span>            : // in {} if you need to use it as the only statement in an 'if'
<span class="lineNum">    1071 </span>            : // branch.
<span class="lineNum">    1072 </span>            : #define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
<span class="lineNum">    1073 </span>            :   if (const int gtest_error = (posix_call)) \
<span class="lineNum">    1074 </span>            :     GTEST_LOG_(FATAL) &lt;&lt; #posix_call &lt;&lt; &quot;failed with error &quot; \
<span class="lineNum">    1075 </span>            :                       &lt;&lt; gtest_error
<span class="lineNum">    1076 </span>            : 
<span class="lineNum">    1077 </span>            : // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
<span class="lineNum">    1078 </span>            : //
<span class="lineNum">    1079 </span>            : // Use ImplicitCast_ as a safe version of static_cast for upcasting in
<span class="lineNum">    1080 </span>            : // the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
<span class="lineNum">    1081 </span>            : // const Foo*).  When you use ImplicitCast_, the compiler checks that
<span class="lineNum">    1082 </span>            : // the cast is safe.  Such explicit ImplicitCast_s are necessary in
<span class="lineNum">    1083 </span>            : // surprisingly many situations where C++ demands an exact type match
<span class="lineNum">    1084 </span>            : // instead of an argument type convertable to a target type.
<span class="lineNum">    1085 </span>            : //
<span class="lineNum">    1086 </span>            : // The syntax for using ImplicitCast_ is the same as for static_cast:
<span class="lineNum">    1087 </span>            : //
<span class="lineNum">    1088 </span>            : //   ImplicitCast_&lt;ToType&gt;(expr)
<span class="lineNum">    1089 </span>            : //
<span class="lineNum">    1090 </span>            : // ImplicitCast_ would have been part of the C++ standard library,
<span class="lineNum">    1091 </span>            : // but the proposal was submitted too late.  It will probably make
<span class="lineNum">    1092 </span>            : // its way into the language in the future.
<span class="lineNum">    1093 </span>            : //
<span class="lineNum">    1094 </span>            : // This relatively ugly name is intentional. It prevents clashes with
<span class="lineNum">    1095 </span>            : // similar functions users may have (e.g., implicit_cast). The internal
<a name="1096"><span class="lineNum">    1096 </span>            : // namespace alone is not enough because the function can be found by ADL.</a>
<span class="lineNum">    1097 </span>            : template&lt;typename To&gt;
<span class="lineNum">    1098 </span><span class="lineNoCov">          0 : inline To ImplicitCast_(To x) { return x; }</span>
<span class="lineNum">    1099 </span>            : 
<span class="lineNum">    1100 </span>            : // When you upcast (that is, cast a pointer from type Foo to type
<span class="lineNum">    1101 </span>            : // SuperclassOfFoo), it's fine to use ImplicitCast_&lt;&gt;, since upcasts
<span class="lineNum">    1102 </span>            : // always succeed.  When you downcast (that is, cast a pointer from
<span class="lineNum">    1103 </span>            : // type Foo to type SubclassOfFoo), static_cast&lt;&gt; isn't safe, because
<span class="lineNum">    1104 </span>            : // how do you know the pointer is really of type SubclassOfFoo?  It
<span class="lineNum">    1105 </span>            : // could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,
<span class="lineNum">    1106 </span>            : // when you downcast, you should use this macro.  In debug mode, we
<span class="lineNum">    1107 </span>            : // use dynamic_cast&lt;&gt; to double-check the downcast is legal (we die
<span class="lineNum">    1108 </span>            : // if it's not).  In normal mode, we do the efficient static_cast&lt;&gt;
<span class="lineNum">    1109 </span>            : // instead.  Thus, it's important to test in debug mode to make sure
<span class="lineNum">    1110 </span>            : // the cast is legal!
<span class="lineNum">    1111 </span>            : //    This is the only place in the code we should use dynamic_cast&lt;&gt;.
<span class="lineNum">    1112 </span>            : // In particular, you SHOULDN'T be using dynamic_cast&lt;&gt; in order to
<span class="lineNum">    1113 </span>            : // do RTTI (eg code like this:
<span class="lineNum">    1114 </span>            : //    if (dynamic_cast&lt;Subclass1&gt;(foo)) HandleASubclass1Object(foo);
<span class="lineNum">    1115 </span>            : //    if (dynamic_cast&lt;Subclass2&gt;(foo)) HandleASubclass2Object(foo);
<span class="lineNum">    1116 </span>            : // You should design the code some other way not to need this.
<span class="lineNum">    1117 </span>            : //
<span class="lineNum">    1118 </span>            : // This relatively ugly name is intentional. It prevents clashes with
<span class="lineNum">    1119 </span>            : // similar functions users may have (e.g., down_cast). The internal
<span class="lineNum">    1120 </span>            : // namespace alone is not enough because the function can be found by ADL.
<span class="lineNum">    1121 </span>            : template&lt;typename To, typename From&gt;  // use like this: DownCast_&lt;T*&gt;(foo);
<span class="lineNum">    1122 </span>            : inline To DownCast_(From* f) {  // so we only accept pointers
<span class="lineNum">    1123 </span>            :   // Ensures that To is a sub-type of From *.  This test is here only
<span class="lineNum">    1124 </span>            :   // for compile-time type checking, and has no overhead in an
<span class="lineNum">    1125 </span>            :   // optimized build at run-time, as it will be optimized away
<span class="lineNum">    1126 </span>            :   // completely.
<span class="lineNum">    1127 </span>            :   if (false) {
<span class="lineNum">    1128 </span>            :     const To to = NULL;
<span class="lineNum">    1129 </span>            :     ::testing::internal::ImplicitCast_&lt;From*&gt;(to);
<span class="lineNum">    1130 </span>            :   }
<span class="lineNum">    1131 </span>            : 
<span class="lineNum">    1132 </span>            : #if GTEST_HAS_RTTI
<span class="lineNum">    1133 </span>            :   // RTTI: debug mode only!
<span class="lineNum">    1134 </span>            :   GTEST_CHECK_(f == NULL || dynamic_cast&lt;To&gt;(f) != NULL);
<span class="lineNum">    1135 </span>            : #endif
<span class="lineNum">    1136 </span>            :   return static_cast&lt;To&gt;(f);
<span class="lineNum">    1137 </span>            : }
<span class="lineNum">    1138 </span>            : 
<span class="lineNum">    1139 </span>            : // Downcasts the pointer of type Base to Derived.
<span class="lineNum">    1140 </span>            : // Derived must be a subclass of Base. The parameter MUST
<span class="lineNum">    1141 </span>            : // point to a class of type Derived, not any subclass of it.
<span class="lineNum">    1142 </span>            : // When RTTI is available, the function performs a runtime
<a name="1143"><span class="lineNum">    1143 </span>            : // check to enforce this.</a>
<span class="lineNum">    1144 </span>            : template &lt;class Derived, class Base&gt;
<span class="lineNum">    1145 </span><span class="lineNoCov">          0 : Derived* CheckedDowncastToActualType(Base* base) {</span>
<span class="lineNum">    1146 </span>            : #if GTEST_HAS_RTTI
<span class="lineNum">    1147 </span><span class="lineNoCov">          0 :   GTEST_CHECK_(typeid(*base) == typeid(Derived));</span>
<span class="lineNum">    1148 </span><span class="lineNoCov">          0 :   return dynamic_cast&lt;Derived*&gt;(base);  // NOLINT</span>
<span class="lineNum">    1149 </span>            : #else
<span class="lineNum">    1150 </span>            :   return static_cast&lt;Derived*&gt;(base);  // Poor man's downcast.
<span class="lineNum">    1151 </span>            : #endif
<span class="lineNum">    1152 </span>            : }
<span class="lineNum">    1153 </span>            : 
<span class="lineNum">    1154 </span>            : #if GTEST_HAS_STREAM_REDIRECTION
<span class="lineNum">    1155 </span>            : 
<span class="lineNum">    1156 </span>            : // Defines the stderr capturer:
<span class="lineNum">    1157 </span>            : //   CaptureStdout     - starts capturing stdout.
<span class="lineNum">    1158 </span>            : //   GetCapturedStdout - stops capturing stdout and returns the captured string.
<span class="lineNum">    1159 </span>            : //   CaptureStderr     - starts capturing stderr.
<span class="lineNum">    1160 </span>            : //   GetCapturedStderr - stops capturing stderr and returns the captured string.
<span class="lineNum">    1161 </span>            : //
<span class="lineNum">    1162 </span>            : GTEST_API_ void CaptureStdout();
<span class="lineNum">    1163 </span>            : GTEST_API_ std::string GetCapturedStdout();
<span class="lineNum">    1164 </span>            : GTEST_API_ void CaptureStderr();
<span class="lineNum">    1165 </span>            : GTEST_API_ std::string GetCapturedStderr();
<span class="lineNum">    1166 </span>            : 
<span class="lineNum">    1167 </span>            : #endif  // GTEST_HAS_STREAM_REDIRECTION
<span class="lineNum">    1168 </span>            : 
<span class="lineNum">    1169 </span>            : 
<span class="lineNum">    1170 </span>            : #if GTEST_HAS_DEATH_TEST
<span class="lineNum">    1171 </span>            : 
<span class="lineNum">    1172 </span>            : const ::std::vector&lt;testing::internal::string&gt;&amp; GetInjectableArgvs();
<span class="lineNum">    1173 </span>            : void SetInjectableArgvs(const ::std::vector&lt;testing::internal::string&gt;*
<span class="lineNum">    1174 </span>            :                              new_argvs);
<span class="lineNum">    1175 </span>            : 
<span class="lineNum">    1176 </span>            : // A copy of all command line arguments.  Set by InitGoogleTest().
<span class="lineNum">    1177 </span>            : extern ::std::vector&lt;testing::internal::string&gt; g_argvs;
<span class="lineNum">    1178 </span>            : 
<span class="lineNum">    1179 </span>            : #endif  // GTEST_HAS_DEATH_TEST
<span class="lineNum">    1180 </span>            : 
<span class="lineNum">    1181 </span>            : // Defines synchronization primitives.
<span class="lineNum">    1182 </span>            : 
<span class="lineNum">    1183 </span>            : #if GTEST_HAS_PTHREAD
<span class="lineNum">    1184 </span>            : 
<span class="lineNum">    1185 </span>            : // Sleeps for (roughly) n milli-seconds.  This function is only for
<span class="lineNum">    1186 </span>            : // testing Google Test's own constructs.  Don't use it in user tests,
<span class="lineNum">    1187 </span>            : // either directly or indirectly.
<span class="lineNum">    1188 </span>            : inline void SleepMilliseconds(int n) {
<span class="lineNum">    1189 </span>            :   const timespec time = {
<span class="lineNum">    1190 </span>            :     0,                  // 0 seconds.
<span class="lineNum">    1191 </span>            :     n * 1000L * 1000L,  // And n ms.
<span class="lineNum">    1192 </span>            :   };
<span class="lineNum">    1193 </span>            :   nanosleep(&amp;time, NULL);
<span class="lineNum">    1194 </span>            : }
<span class="lineNum">    1195 </span>            : 
<span class="lineNum">    1196 </span>            : // Allows a controller thread to pause execution of newly created
<span class="lineNum">    1197 </span>            : // threads until notified.  Instances of this class must be created
<span class="lineNum">    1198 </span>            : // and destroyed in the controller thread.
<span class="lineNum">    1199 </span>            : //
<span class="lineNum">    1200 </span>            : // This class is only for testing Google Test's own constructs. Do not
<span class="lineNum">    1201 </span>            : // use it in user tests, either directly or indirectly.
<span class="lineNum">    1202 </span>            : class Notification {
<span class="lineNum">    1203 </span>            :  public:
<span class="lineNum">    1204 </span>            :   Notification() : notified_(false) {
<span class="lineNum">    1205 </span>            :     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&amp;mutex_, NULL));
<span class="lineNum">    1206 </span>            :   }
<span class="lineNum">    1207 </span>            :   ~Notification() {
<span class="lineNum">    1208 </span>            :     pthread_mutex_destroy(&amp;mutex_);
<span class="lineNum">    1209 </span>            :   }
<span class="lineNum">    1210 </span>            : 
<span class="lineNum">    1211 </span>            :   // Notifies all threads created with this notification to start. Must
<span class="lineNum">    1212 </span>            :   // be called from the controller thread.
<span class="lineNum">    1213 </span>            :   void Notify() {
<span class="lineNum">    1214 </span>            :     pthread_mutex_lock(&amp;mutex_);
<span class="lineNum">    1215 </span>            :     notified_ = true;
<span class="lineNum">    1216 </span>            :     pthread_mutex_unlock(&amp;mutex_);
<span class="lineNum">    1217 </span>            :   }
<span class="lineNum">    1218 </span>            : 
<span class="lineNum">    1219 </span>            :   // Blocks until the controller thread notifies. Must be called from a test
<span class="lineNum">    1220 </span>            :   // thread.
<span class="lineNum">    1221 </span>            :   void WaitForNotification() {
<span class="lineNum">    1222 </span>            :     for (;;) {
<span class="lineNum">    1223 </span>            :       pthread_mutex_lock(&amp;mutex_);
<span class="lineNum">    1224 </span>            :       const bool notified = notified_;
<span class="lineNum">    1225 </span>            :       pthread_mutex_unlock(&amp;mutex_);
<span class="lineNum">    1226 </span>            :       if (notified)
<span class="lineNum">    1227 </span>            :         break;
<span class="lineNum">    1228 </span>            :       SleepMilliseconds(10);
<span class="lineNum">    1229 </span>            :     }
<span class="lineNum">    1230 </span>            :   }
<span class="lineNum">    1231 </span>            : 
<span class="lineNum">    1232 </span>            :  private:
<span class="lineNum">    1233 </span>            :   pthread_mutex_t mutex_;
<span class="lineNum">    1234 </span>            :   bool notified_;
<span class="lineNum">    1235 </span>            : 
<span class="lineNum">    1236 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
<span class="lineNum">    1237 </span>            : };
<span class="lineNum">    1238 </span>            : 
<span class="lineNum">    1239 </span>            : // As a C-function, ThreadFuncWithCLinkage cannot be templated itself.
<span class="lineNum">    1240 </span>            : // Consequently, it cannot select a correct instantiation of ThreadWithParam
<span class="lineNum">    1241 </span>            : // in order to call its Run(). Introducing ThreadWithParamBase as a
<span class="lineNum">    1242 </span>            : // non-templated base class for ThreadWithParam allows us to bypass this
<span class="lineNum">    1243 </span>            : // problem.
<span class="lineNum">    1244 </span>            : class ThreadWithParamBase {
<span class="lineNum">    1245 </span>            :  public:
<span class="lineNum">    1246 </span>            :   virtual ~ThreadWithParamBase() {}
<span class="lineNum">    1247 </span>            :   virtual void Run() = 0;
<span class="lineNum">    1248 </span>            : };
<span class="lineNum">    1249 </span>            : 
<span class="lineNum">    1250 </span>            : // pthread_create() accepts a pointer to a function type with the C linkage.
<span class="lineNum">    1251 </span>            : // According to the Standard (7.5/1), function types with different linkages
<span class="lineNum">    1252 </span>            : // are different even if they are otherwise identical.  Some compilers (for
<span class="lineNum">    1253 </span>            : // example, SunStudio) treat them as different types.  Since class methods
<span class="lineNum">    1254 </span>            : // cannot be defined with C-linkage we need to define a free C-function to
<span class="lineNum">    1255 </span>            : // pass into pthread_create().
<span class="lineNum">    1256 </span>            : extern &quot;C&quot; inline void* ThreadFuncWithCLinkage(void* thread) {
<span class="lineNum">    1257 </span>            :   static_cast&lt;ThreadWithParamBase*&gt;(thread)-&gt;Run();
<span class="lineNum">    1258 </span>            :   return NULL;
<span class="lineNum">    1259 </span>            : }
<span class="lineNum">    1260 </span>            : 
<span class="lineNum">    1261 </span>            : // Helper class for testing Google Test's multi-threading constructs.
<span class="lineNum">    1262 </span>            : // To use it, write:
<span class="lineNum">    1263 </span>            : //
<span class="lineNum">    1264 </span>            : //   void ThreadFunc(int param) { /* Do things with param */ }
<span class="lineNum">    1265 </span>            : //   Notification thread_can_start;
<span class="lineNum">    1266 </span>            : //   ...
<span class="lineNum">    1267 </span>            : //   // The thread_can_start parameter is optional; you can supply NULL.
<span class="lineNum">    1268 </span>            : //   ThreadWithParam&lt;int&gt; thread(&amp;ThreadFunc, 5, &amp;thread_can_start);
<span class="lineNum">    1269 </span>            : //   thread_can_start.Notify();
<span class="lineNum">    1270 </span>            : //
<span class="lineNum">    1271 </span>            : // These classes are only for testing Google Test's own constructs. Do
<span class="lineNum">    1272 </span>            : // not use them in user tests, either directly or indirectly.
<span class="lineNum">    1273 </span>            : template &lt;typename T&gt;
<span class="lineNum">    1274 </span>            : class ThreadWithParam : public ThreadWithParamBase {
<span class="lineNum">    1275 </span>            :  public:
<span class="lineNum">    1276 </span>            :   typedef void (*UserThreadFunc)(T);
<span class="lineNum">    1277 </span>            : 
<span class="lineNum">    1278 </span>            :   ThreadWithParam(
<span class="lineNum">    1279 </span>            :       UserThreadFunc func, T param, Notification* thread_can_start)
<span class="lineNum">    1280 </span>            :       : func_(func),
<span class="lineNum">    1281 </span>            :         param_(param),
<span class="lineNum">    1282 </span>            :         thread_can_start_(thread_can_start),
<span class="lineNum">    1283 </span>            :         finished_(false) {
<span class="lineNum">    1284 </span>            :     ThreadWithParamBase* const base = this;
<span class="lineNum">    1285 </span>            :     // The thread can be created only after all fields except thread_
<span class="lineNum">    1286 </span>            :     // have been initialized.
<span class="lineNum">    1287 </span>            :     GTEST_CHECK_POSIX_SUCCESS_(
<span class="lineNum">    1288 </span>            :         pthread_create(&amp;thread_, 0, &amp;ThreadFuncWithCLinkage, base));
<span class="lineNum">    1289 </span>            :   }
<span class="lineNum">    1290 </span>            :   ~ThreadWithParam() { Join(); }
<span class="lineNum">    1291 </span>            : 
<span class="lineNum">    1292 </span>            :   void Join() {
<span class="lineNum">    1293 </span>            :     if (!finished_) {
<span class="lineNum">    1294 </span>            :       GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, 0));
<span class="lineNum">    1295 </span>            :       finished_ = true;
<span class="lineNum">    1296 </span>            :     }
<span class="lineNum">    1297 </span>            :   }
<span class="lineNum">    1298 </span>            : 
<span class="lineNum">    1299 </span>            :   virtual void Run() {
<span class="lineNum">    1300 </span>            :     if (thread_can_start_ != NULL)
<span class="lineNum">    1301 </span>            :       thread_can_start_-&gt;WaitForNotification();
<span class="lineNum">    1302 </span>            :     func_(param_);
<span class="lineNum">    1303 </span>            :   }
<span class="lineNum">    1304 </span>            : 
<span class="lineNum">    1305 </span>            :  private:
<span class="lineNum">    1306 </span>            :   const UserThreadFunc func_;  // User-supplied thread function.
<span class="lineNum">    1307 </span>            :   const T param_;  // User-supplied parameter to the thread function.
<span class="lineNum">    1308 </span>            :   // When non-NULL, used to block execution until the controller thread
<span class="lineNum">    1309 </span>            :   // notifies.
<span class="lineNum">    1310 </span>            :   Notification* const thread_can_start_;
<span class="lineNum">    1311 </span>            :   bool finished_;  // true iff we know that the thread function has finished.
<span class="lineNum">    1312 </span>            :   pthread_t thread_;  // The native thread object.
<span class="lineNum">    1313 </span>            : 
<span class="lineNum">    1314 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
<span class="lineNum">    1315 </span>            : };
<span class="lineNum">    1316 </span>            : 
<span class="lineNum">    1317 </span>            : // MutexBase and Mutex implement mutex on pthreads-based platforms. They
<span class="lineNum">    1318 </span>            : // are used in conjunction with class MutexLock:
<span class="lineNum">    1319 </span>            : //
<span class="lineNum">    1320 </span>            : //   Mutex mutex;
<span class="lineNum">    1321 </span>            : //   ...
<span class="lineNum">    1322 </span>            : //   MutexLock lock(&amp;mutex);  // Acquires the mutex and releases it at the end
<span class="lineNum">    1323 </span>            : //                            // of the current scope.
<span class="lineNum">    1324 </span>            : //
<span class="lineNum">    1325 </span>            : // MutexBase implements behavior for both statically and dynamically
<span class="lineNum">    1326 </span>            : // allocated mutexes.  Do not use MutexBase directly.  Instead, write
<span class="lineNum">    1327 </span>            : // the following to define a static mutex:
<span class="lineNum">    1328 </span>            : //
<span class="lineNum">    1329 </span>            : //   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);
<span class="lineNum">    1330 </span>            : //
<span class="lineNum">    1331 </span>            : // You can forward declare a static mutex like this:
<span class="lineNum">    1332 </span>            : //
<span class="lineNum">    1333 </span>            : //   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);
<a name="1334"><span class="lineNum">    1334 </span>            : //</a>
<span class="lineNum">    1335 </span>            : // To create a dynamic mutex, just define an object of type Mutex.
<span class="lineNum">    1336 </span><span class="lineNoCov">          0 : class MutexBase {</span>
<a name="1337"><span class="lineNum">    1337 </span>            :  public:</a>
<span class="lineNum">    1338 </span>            :   // Acquires this mutex.
<span class="lineNum">    1339 </span><span class="lineNoCov">          0 :   void Lock() {</span>
<span class="lineNum">    1340 </span><span class="lineNoCov">          0 :     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&amp;mutex_));</span>
<span class="lineNum">    1341 </span><span class="lineNoCov">          0 :     owner_ = pthread_self();</span>
<span class="lineNum">    1342 </span><span class="lineNoCov">          0 :     has_owner_ = true;</span>
<span class="lineNum">    1343 </span><span class="lineNoCov">          0 :   }</span>
<a name="1344"><span class="lineNum">    1344 </span>            : </a>
<span class="lineNum">    1345 </span>            :   // Releases this mutex.
<span class="lineNum">    1346 </span><span class="lineNoCov">          0 :   void Unlock() {</span>
<span class="lineNum">    1347 </span>            :     // Since the lock is being released the owner_ field should no longer be
<span class="lineNum">    1348 </span>            :     // considered valid. We don't protect writing to has_owner_ here, as it's
<span class="lineNum">    1349 </span>            :     // the caller's responsibility to ensure that the current thread holds the
<span class="lineNum">    1350 </span>            :     // mutex when this is called.
<span class="lineNum">    1351 </span><span class="lineNoCov">          0 :     has_owner_ = false;</span>
<span class="lineNum">    1352 </span><span class="lineNoCov">          0 :     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&amp;mutex_));</span>
<span class="lineNum">    1353 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">    1354 </span>            : 
<a name="1355"><span class="lineNum">    1355 </span>            :   // Does nothing if the current thread holds the mutex. Otherwise, crashes</a>
<span class="lineNum">    1356 </span>            :   // with high probability.
<span class="lineNum">    1357 </span><span class="lineNoCov">          0 :   void AssertHeld() const {</span>
<span class="lineNum">    1358 </span><span class="lineNoCov">          0 :     GTEST_CHECK_(has_owner_ &amp;&amp; pthread_equal(owner_, pthread_self()))</span>
<span class="lineNum">    1359 </span><span class="lineNoCov">          0 :         &lt;&lt; &quot;The current thread is not holding the mutex @&quot; &lt;&lt; this;</span>
<span class="lineNum">    1360 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">    1361 </span>            : 
<span class="lineNum">    1362 </span>            :   // A static mutex may be used before main() is entered.  It may even
<span class="lineNum">    1363 </span>            :   // be used before the dynamic initialization stage.  Therefore we
<span class="lineNum">    1364 </span>            :   // must be able to initialize a static mutex object at link time.
<span class="lineNum">    1365 </span>            :   // This means MutexBase has to be a POD and its member variables
<span class="lineNum">    1366 </span>            :   // have to be public.
<span class="lineNum">    1367 </span>            :  public:
<span class="lineNum">    1368 </span>            :   pthread_mutex_t mutex_;  // The underlying pthread mutex.
<span class="lineNum">    1369 </span>            :   // has_owner_ indicates whether the owner_ field below contains a valid thread
<span class="lineNum">    1370 </span>            :   // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All
<span class="lineNum">    1371 </span>            :   // accesses to the owner_ field should be protected by a check of this field.
<span class="lineNum">    1372 </span>            :   // An alternative might be to memset() owner_ to all zeros, but there's no
<span class="lineNum">    1373 </span>            :   // guarantee that a zero'd pthread_t is necessarily invalid or even different
<span class="lineNum">    1374 </span>            :   // from pthread_self().
<span class="lineNum">    1375 </span>            :   bool has_owner_;
<span class="lineNum">    1376 </span>            :   pthread_t owner_;  // The thread holding the mutex.
<span class="lineNum">    1377 </span>            : };
<span class="lineNum">    1378 </span>            : 
<span class="lineNum">    1379 </span>            : // Forward-declares a static mutex.
<span class="lineNum">    1380 </span>            : # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
<span class="lineNum">    1381 </span>            :     extern ::testing::internal::MutexBase mutex
<span class="lineNum">    1382 </span>            : 
<span class="lineNum">    1383 </span>            : // Defines and statically (i.e. at link time) initializes a static mutex.
<span class="lineNum">    1384 </span>            : // The initialization list here does not explicitly initialize each field,
<span class="lineNum">    1385 </span>            : // instead relying on default initialization for the unspecified fields. In
<span class="lineNum">    1386 </span>            : // particular, the owner_ field (a pthread_t) is not explicitly initialized.
<span class="lineNum">    1387 </span>            : // This allows initialization to work whether pthread_t is a scalar or struct.
<span class="lineNum">    1388 </span>            : // The flag -Wmissing-field-initializers must not be specified for this to work.
<span class="lineNum">    1389 </span>            : # define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
<span class="lineNum">    1390 </span>            :     ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false }
<span class="lineNum">    1391 </span>            : 
<span class="lineNum">    1392 </span>            : // The Mutex class can only be used for mutexes created at runtime. It
<span class="lineNum">    1393 </span>            : // shares its API with MutexBase otherwise.
<a name="1394"><span class="lineNum">    1394 </span>            : class Mutex : public MutexBase {</a>
<span class="lineNum">    1395 </span>            :  public:
<span class="lineNum">    1396 </span><span class="lineNoCov">          0 :   Mutex() {</span>
<span class="lineNum">    1397 </span><span class="lineNoCov">          0 :     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&amp;mutex_, NULL));</span>
<a name="1398"><span class="lineNum">    1398 </span><span class="lineNoCov">          0 :     has_owner_ = false;</span></a>
<span class="lineNum">    1399 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">    1400 </span><span class="lineNoCov">          0 :   ~Mutex() {</span>
<span class="lineNum">    1401 </span><span class="lineNoCov">          0 :     GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&amp;mutex_));</span>
<span class="lineNum">    1402 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">    1403 </span>            : 
<span class="lineNum">    1404 </span>            :  private:
<span class="lineNum">    1405 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
<span class="lineNum">    1406 </span>            : };
<span class="lineNum">    1407 </span>            : 
<span class="lineNum">    1408 </span>            : // We cannot name this class MutexLock as the ctor declaration would
<span class="lineNum">    1409 </span>            : // conflict with a macro named MutexLock, which is defined on some
<span class="lineNum">    1410 </span>            : // platforms.  Hence the typedef trick below.
<a name="1411"><span class="lineNum">    1411 </span>            : class GTestMutexLock {</a>
<span class="lineNum">    1412 </span>            :  public:
<span class="lineNum">    1413 </span><span class="lineNoCov">          0 :   explicit GTestMutexLock(MutexBase* mutex)</span>
<a name="1414"><span class="lineNum">    1414 </span><span class="lineNoCov">          0 :       : mutex_(mutex) { mutex_-&gt;Lock(); }</span></a>
<span class="lineNum">    1415 </span>            : 
<span class="lineNum">    1416 </span><span class="lineNoCov">          0 :   ~GTestMutexLock() { mutex_-&gt;Unlock(); }</span>
<span class="lineNum">    1417 </span>            : 
<span class="lineNum">    1418 </span>            :  private:
<span class="lineNum">    1419 </span>            :   MutexBase* const mutex_;
<span class="lineNum">    1420 </span>            : 
<span class="lineNum">    1421 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
<span class="lineNum">    1422 </span>            : };
<span class="lineNum">    1423 </span>            : 
<span class="lineNum">    1424 </span>            : typedef GTestMutexLock MutexLock;
<span class="lineNum">    1425 </span>            : 
<span class="lineNum">    1426 </span>            : // Helpers for ThreadLocal.
<span class="lineNum">    1427 </span>            : 
<span class="lineNum">    1428 </span>            : // pthread_key_create() requires DeleteThreadLocalValue() to have
<span class="lineNum">    1429 </span>            : // C-linkage.  Therefore it cannot be templatized to access
<a name="1430"><span class="lineNum">    1430 </span>            : // ThreadLocal&lt;T&gt;.  Hence the need for class</a>
<span class="lineNum">    1431 </span>            : // ThreadLocalValueHolderBase.
<a name="1432"><span class="lineNum">    1432 </span><span class="lineNoCov">          0 : class ThreadLocalValueHolderBase {</span></a>
<span class="lineNum">    1433 </span>            :  public:
<span class="lineNum">    1434 </span><span class="lineNoCov">          0 :   virtual ~ThreadLocalValueHolderBase() {}</span>
<span class="lineNum">    1435 </span>            : };
<span class="lineNum">    1436 </span>            : 
<a name="1437"><span class="lineNum">    1437 </span>            : // Called by pthread to delete thread-local data stored by</a>
<span class="lineNum">    1438 </span>            : // pthread_setspecific().
<span class="lineNum">    1439 </span><span class="lineNoCov">          0 : extern &quot;C&quot; inline void DeleteThreadLocalValue(void* value_holder) {</span>
<span class="lineNum">    1440 </span><span class="lineNoCov">          0 :   delete static_cast&lt;ThreadLocalValueHolderBase*&gt;(value_holder);</span>
<span class="lineNum">    1441 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">    1442 </span>            : 
<span class="lineNum">    1443 </span>            : // Implements thread-local storage on pthreads-based systems.
<span class="lineNum">    1444 </span>            : //
<span class="lineNum">    1445 </span>            : //   // Thread 1
<span class="lineNum">    1446 </span>            : //   ThreadLocal&lt;int&gt; tl(100);  // 100 is the default value for each thread.
<span class="lineNum">    1447 </span>            : //
<span class="lineNum">    1448 </span>            : //   // Thread 2
<span class="lineNum">    1449 </span>            : //   tl.set(150);  // Changes the value for thread 2 only.
<span class="lineNum">    1450 </span>            : //   EXPECT_EQ(150, tl.get());
<span class="lineNum">    1451 </span>            : //
<span class="lineNum">    1452 </span>            : //   // Thread 1
<span class="lineNum">    1453 </span>            : //   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.
<span class="lineNum">    1454 </span>            : //   tl.set(200);
<span class="lineNum">    1455 </span>            : //   EXPECT_EQ(200, tl.get());
<span class="lineNum">    1456 </span>            : //
<span class="lineNum">    1457 </span>            : // The template type argument T must have a public copy constructor.
<span class="lineNum">    1458 </span>            : // In addition, the default ThreadLocal constructor requires T to have
<span class="lineNum">    1459 </span>            : // a public default constructor.
<span class="lineNum">    1460 </span>            : //
<span class="lineNum">    1461 </span>            : // An object managed for a thread by a ThreadLocal instance is deleted
<span class="lineNum">    1462 </span>            : // when the thread exits.  Or, if the ThreadLocal instance dies in
<span class="lineNum">    1463 </span>            : // that thread, when the ThreadLocal dies.  It's the user's
<span class="lineNum">    1464 </span>            : // responsibility to ensure that all other threads using a ThreadLocal
<span class="lineNum">    1465 </span>            : // have exited when it dies, or the per-thread objects for those
<span class="lineNum">    1466 </span>            : // threads will not be deleted.
<span class="lineNum">    1467 </span>            : //
<span class="lineNum">    1468 </span>            : // Google Test only uses global ThreadLocal objects.  That means they
<span class="lineNum">    1469 </span>            : // will die after main() has returned.  Therefore, no per-thread
<span class="lineNum">    1470 </span>            : // object managed by Google Test will be leaked as long as all threads
<span class="lineNum">    1471 </span>            : // using Google Test have exited when main() returns.
<span class="lineNum">    1472 </span>            : template &lt;typename T&gt;
<a name="1473"><span class="lineNum">    1473 </span>            : class ThreadLocal {</a>
<span class="lineNum">    1474 </span>            :  public:
<a name="1475"><span class="lineNum">    1475 </span><span class="lineNoCov">          0 :   ThreadLocal() : key_(CreateKey()),</span></a>
<span class="lineNum">    1476 </span><span class="lineNoCov">          0 :                   default_() {}</span>
<span class="lineNum">    1477 </span><span class="lineNoCov">          0 :   explicit ThreadLocal(const T&amp; value) : key_(CreateKey()),</span>
<a name="1478"><span class="lineNum">    1478 </span><span class="lineNoCov">          0 :                                          default_(value) {}</span></a>
<span class="lineNum">    1479 </span>            : 
<span class="lineNum">    1480 </span><span class="lineNoCov">          0 :   ~ThreadLocal() {</span>
<span class="lineNum">    1481 </span>            :     // Destroys the managed object for the current thread, if any.
<span class="lineNum">    1482 </span><span class="lineNoCov">          0 :     DeleteThreadLocalValue(pthread_getspecific(key_));</span>
<span class="lineNum">    1483 </span>            : 
<span class="lineNum">    1484 </span>            :     // Releases resources associated with the key.  This will *not*
<span class="lineNum">    1485 </span>            :     // delete managed objects for other threads.
<span class="lineNum">    1486 </span><span class="lineNoCov">          0 :     GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));</span>
<a name="1487"><span class="lineNum">    1487 </span><span class="lineNoCov">          0 :   }</span></a>
<a name="1488"><span class="lineNum">    1488 </span>            : </a>
<a name="1489"><span class="lineNum">    1489 </span><span class="lineNoCov">          0 :   T* pointer() { return GetOrCreateValue(); }</span></a>
<a name="1490"><span class="lineNum">    1490 </span><span class="lineNoCov">          0 :   const T* pointer() const { return GetOrCreateValue(); }</span></a>
<span class="lineNum">    1491 </span><span class="lineNoCov">          0 :   const T&amp; get() const { return *pointer(); }</span>
<span class="lineNum">    1492 </span><span class="lineNoCov">          0 :   void set(const T&amp; value) { *pointer() = value; }</span>
<span class="lineNum">    1493 </span>            : 
<a name="1494"><span class="lineNum">    1494 </span>            :  private:</a>
<span class="lineNum">    1495 </span>            :   // Holds a value of type T.
<a name="1496"><span class="lineNum">    1496 </span><span class="lineNoCov">          0 :   class ValueHolder : public ThreadLocalValueHolderBase {</span></a>
<span class="lineNum">    1497 </span>            :    public:
<a name="1498"><span class="lineNum">    1498 </span><span class="lineNoCov">          0 :     explicit ValueHolder(const T&amp; value) : value_(value) {}</span></a>
<span class="lineNum">    1499 </span>            : 
<span class="lineNum">    1500 </span><span class="lineNoCov">          0 :     T* pointer() { return &amp;value_; }</span>
<span class="lineNum">    1501 </span>            : 
<span class="lineNum">    1502 </span>            :    private:
<span class="lineNum">    1503 </span>            :     T value_;
<span class="lineNum">    1504 </span>            :     GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
<a name="1505"><span class="lineNum">    1505 </span>            :   };</a>
<span class="lineNum">    1506 </span>            : 
<span class="lineNum">    1507 </span><span class="lineNoCov">          0 :   static pthread_key_t CreateKey() {</span>
<span class="lineNum">    1508 </span>            :     pthread_key_t key;
<span class="lineNum">    1509 </span>            :     // When a thread exits, DeleteThreadLocalValue() will be called on
<span class="lineNum">    1510 </span>            :     // the object managed for that thread.
<span class="lineNum">    1511 </span><span class="lineNoCov">          0 :     GTEST_CHECK_POSIX_SUCCESS_(</span>
<span class="lineNum">    1512 </span>            :         pthread_key_create(&amp;key, &amp;DeleteThreadLocalValue));
<span class="lineNum">    1513 </span><span class="lineNoCov">          0 :     return key;</span>
<a name="1514"><span class="lineNum">    1514 </span>            :   }</a>
<span class="lineNum">    1515 </span>            : 
<span class="lineNum">    1516 </span><span class="lineNoCov">          0 :   T* GetOrCreateValue() const {</span>
<span class="lineNum">    1517 </span>            :     ThreadLocalValueHolderBase* const holder =
<span class="lineNum">    1518 </span><span class="lineNoCov">          0 :         static_cast&lt;ThreadLocalValueHolderBase*&gt;(pthread_getspecific(key_));</span>
<span class="lineNum">    1519 </span><span class="lineNoCov">          0 :     if (holder != NULL) {</span>
<span class="lineNum">    1520 </span><span class="lineNoCov">          0 :       return CheckedDowncastToActualType&lt;ValueHolder&gt;(holder)-&gt;pointer();</span>
<span class="lineNum">    1521 </span>            :     }
<span class="lineNum">    1522 </span>            : 
<span class="lineNum">    1523 </span><span class="lineNoCov">          0 :     ValueHolder* const new_holder = new ValueHolder(default_);</span>
<span class="lineNum">    1524 </span><span class="lineNoCov">          0 :     ThreadLocalValueHolderBase* const holder_base = new_holder;</span>
<span class="lineNum">    1525 </span><span class="lineNoCov">          0 :     GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));</span>
<span class="lineNum">    1526 </span><span class="lineNoCov">          0 :     return new_holder-&gt;pointer();</span>
<span class="lineNum">    1527 </span>            :   }
<span class="lineNum">    1528 </span>            : 
<span class="lineNum">    1529 </span>            :   // A key pthreads uses for looking up per-thread values.
<span class="lineNum">    1530 </span>            :   const pthread_key_t key_;
<span class="lineNum">    1531 </span>            :   const T default_;  // The default value for each thread.
<span class="lineNum">    1532 </span>            : 
<span class="lineNum">    1533 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
<span class="lineNum">    1534 </span>            : };
<span class="lineNum">    1535 </span>            : 
<span class="lineNum">    1536 </span>            : # define GTEST_IS_THREADSAFE 1
<span class="lineNum">    1537 </span>            : 
<span class="lineNum">    1538 </span>            : #else  // GTEST_HAS_PTHREAD
<span class="lineNum">    1539 </span>            : 
<span class="lineNum">    1540 </span>            : // A dummy implementation of synchronization primitives (mutex, lock,
<span class="lineNum">    1541 </span>            : // and thread-local variable).  Necessary for compiling Google Test where
<span class="lineNum">    1542 </span>            : // mutex is not supported - using Google Test in multiple threads is not
<span class="lineNum">    1543 </span>            : // supported on such platforms.
<span class="lineNum">    1544 </span>            : 
<span class="lineNum">    1545 </span>            : class Mutex {
<span class="lineNum">    1546 </span>            :  public:
<span class="lineNum">    1547 </span>            :   Mutex() {}
<span class="lineNum">    1548 </span>            :   void Lock() {}
<span class="lineNum">    1549 </span>            :   void Unlock() {}
<span class="lineNum">    1550 </span>            :   void AssertHeld() const {}
<span class="lineNum">    1551 </span>            : };
<span class="lineNum">    1552 </span>            : 
<span class="lineNum">    1553 </span>            : # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
<span class="lineNum">    1554 </span>            :   extern ::testing::internal::Mutex mutex
<span class="lineNum">    1555 </span>            : 
<span class="lineNum">    1556 </span>            : # define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
<span class="lineNum">    1557 </span>            : 
<span class="lineNum">    1558 </span>            : class GTestMutexLock {
<span class="lineNum">    1559 </span>            :  public:
<span class="lineNum">    1560 </span>            :   explicit GTestMutexLock(Mutex*) {}  // NOLINT
<span class="lineNum">    1561 </span>            : };
<span class="lineNum">    1562 </span>            : 
<span class="lineNum">    1563 </span>            : typedef GTestMutexLock MutexLock;
<span class="lineNum">    1564 </span>            : 
<span class="lineNum">    1565 </span>            : template &lt;typename T&gt;
<span class="lineNum">    1566 </span>            : class ThreadLocal {
<span class="lineNum">    1567 </span>            :  public:
<span class="lineNum">    1568 </span>            :   ThreadLocal() : value_() {}
<span class="lineNum">    1569 </span>            :   explicit ThreadLocal(const T&amp; value) : value_(value) {}
<span class="lineNum">    1570 </span>            :   T* pointer() { return &amp;value_; }
<span class="lineNum">    1571 </span>            :   const T* pointer() const { return &amp;value_; }
<span class="lineNum">    1572 </span>            :   const T&amp; get() const { return value_; }
<span class="lineNum">    1573 </span>            :   void set(const T&amp; value) { value_ = value; }
<span class="lineNum">    1574 </span>            :  private:
<span class="lineNum">    1575 </span>            :   T value_;
<span class="lineNum">    1576 </span>            : };
<span class="lineNum">    1577 </span>            : 
<span class="lineNum">    1578 </span>            : // The above synchronization primitives have dummy implementations.
<span class="lineNum">    1579 </span>            : // Therefore Google Test is not thread-safe.
<span class="lineNum">    1580 </span>            : # define GTEST_IS_THREADSAFE 0
<span class="lineNum">    1581 </span>            : 
<span class="lineNum">    1582 </span>            : #endif  // GTEST_HAS_PTHREAD
<span class="lineNum">    1583 </span>            : 
<span class="lineNum">    1584 </span>            : // Returns the number of threads running in the process, or 0 to indicate that
<span class="lineNum">    1585 </span>            : // we cannot detect it.
<span class="lineNum">    1586 </span>            : GTEST_API_ size_t GetThreadCount();
<span class="lineNum">    1587 </span>            : 
<span class="lineNum">    1588 </span>            : // Passing non-POD classes through ellipsis (...) crashes the ARM
<span class="lineNum">    1589 </span>            : // compiler and generates a warning in Sun Studio.  The Nokia Symbian
<span class="lineNum">    1590 </span>            : // and the IBM XL C/C++ compiler try to instantiate a copy constructor
<span class="lineNum">    1591 </span>            : // for objects passed through ellipsis (...), failing for uncopyable
<span class="lineNum">    1592 </span>            : // objects.  We define this to ensure that only POD is passed through
<span class="lineNum">    1593 </span>            : // ellipsis on these systems.
<span class="lineNum">    1594 </span>            : #if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
<span class="lineNum">    1595 </span>            : // We lose support for NULL detection where the compiler doesn't like
<span class="lineNum">    1596 </span>            : // passing non-POD classes through ellipsis (...).
<span class="lineNum">    1597 </span>            : # define GTEST_ELLIPSIS_NEEDS_POD_ 1
<span class="lineNum">    1598 </span>            : #else
<span class="lineNum">    1599 </span>            : # define GTEST_CAN_COMPARE_NULL 1
<span class="lineNum">    1600 </span>            : #endif
<span class="lineNum">    1601 </span>            : 
<span class="lineNum">    1602 </span>            : // The Nokia Symbian and IBM XL C/C++ compilers cannot decide between
<span class="lineNum">    1603 </span>            : // const T&amp; and const T* in a function template.  These compilers
<span class="lineNum">    1604 </span>            : // _can_ decide between class template specializations for T and T*,
<span class="lineNum">    1605 </span>            : // so a tr1::type_traits-like is_pointer works.
<span class="lineNum">    1606 </span>            : #if defined(__SYMBIAN32__) || defined(__IBMCPP__)
<span class="lineNum">    1607 </span>            : # define GTEST_NEEDS_IS_POINTER_ 1
<span class="lineNum">    1608 </span>            : #endif
<span class="lineNum">    1609 </span>            : 
<span class="lineNum">    1610 </span>            : template &lt;bool bool_value&gt;
<span class="lineNum">    1611 </span>            : struct bool_constant {
<span class="lineNum">    1612 </span>            :   typedef bool_constant&lt;bool_value&gt; type;
<span class="lineNum">    1613 </span>            :   static const bool value = bool_value;
<span class="lineNum">    1614 </span>            : };
<span class="lineNum">    1615 </span>            : template &lt;bool bool_value&gt; const bool bool_constant&lt;bool_value&gt;::value;
<span class="lineNum">    1616 </span>            : 
<span class="lineNum">    1617 </span>            : typedef bool_constant&lt;false&gt; false_type;
<span class="lineNum">    1618 </span>            : typedef bool_constant&lt;true&gt; true_type;
<span class="lineNum">    1619 </span>            : 
<span class="lineNum">    1620 </span>            : template &lt;typename T&gt;
<span class="lineNum">    1621 </span>            : struct is_pointer : public false_type {};
<span class="lineNum">    1622 </span>            : 
<span class="lineNum">    1623 </span>            : template &lt;typename T&gt;
<span class="lineNum">    1624 </span>            : struct is_pointer&lt;T*&gt; : public true_type {};
<span class="lineNum">    1625 </span>            : 
<span class="lineNum">    1626 </span>            : template &lt;typename Iterator&gt;
<span class="lineNum">    1627 </span>            : struct IteratorTraits {
<span class="lineNum">    1628 </span>            :   typedef typename Iterator::value_type value_type;
<span class="lineNum">    1629 </span>            : };
<span class="lineNum">    1630 </span>            : 
<span class="lineNum">    1631 </span>            : template &lt;typename T&gt;
<span class="lineNum">    1632 </span>            : struct IteratorTraits&lt;T*&gt; {
<span class="lineNum">    1633 </span>            :   typedef T value_type;
<span class="lineNum">    1634 </span>            : };
<span class="lineNum">    1635 </span>            : 
<span class="lineNum">    1636 </span>            : template &lt;typename T&gt;
<span class="lineNum">    1637 </span>            : struct IteratorTraits&lt;const T*&gt; {
<span class="lineNum">    1638 </span>            :   typedef T value_type;
<span class="lineNum">    1639 </span>            : };
<span class="lineNum">    1640 </span>            : 
<span class="lineNum">    1641 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">    1642 </span>            : # define GTEST_PATH_SEP_ &quot;\\&quot;
<span class="lineNum">    1643 </span>            : # define GTEST_HAS_ALT_PATH_SEP_ 1
<span class="lineNum">    1644 </span>            : // The biggest signed integer type the compiler supports.
<span class="lineNum">    1645 </span>            : typedef __int64 BiggestInt;
<span class="lineNum">    1646 </span>            : #else
<span class="lineNum">    1647 </span>            : # define GTEST_PATH_SEP_ &quot;/&quot;
<span class="lineNum">    1648 </span>            : # define GTEST_HAS_ALT_PATH_SEP_ 0
<span class="lineNum">    1649 </span>            : typedef long long BiggestInt;  // NOLINT
<span class="lineNum">    1650 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">    1651 </span>            : 
<span class="lineNum">    1652 </span>            : // Utilities for char.
<span class="lineNum">    1653 </span>            : 
<span class="lineNum">    1654 </span>            : // isspace(int ch) and friends accept an unsigned char or EOF.  char
<span class="lineNum">    1655 </span>            : // may be signed, depending on the compiler (or compiler flags).
<span class="lineNum">    1656 </span>            : // Therefore we need to cast a char to unsigned char before calling
<a name="1657"><span class="lineNum">    1657 </span>            : // isspace(), etc.</a>
<span class="lineNum">    1658 </span>            : 
<span class="lineNum">    1659 </span><span class="lineNoCov">          0 : inline bool IsAlpha(char ch) {</span>
<a name="1660"><span class="lineNum">    1660 </span><span class="lineNoCov">          0 :   return isalpha(static_cast&lt;unsigned char&gt;(ch)) != 0;</span></a>
<span class="lineNum">    1661 </span>            : }
<span class="lineNum">    1662 </span><span class="lineNoCov">          0 : inline bool IsAlNum(char ch) {</span>
<a name="1663"><span class="lineNum">    1663 </span><span class="lineNoCov">          0 :   return isalnum(static_cast&lt;unsigned char&gt;(ch)) != 0;</span></a>
<span class="lineNum">    1664 </span>            : }
<span class="lineNum">    1665 </span><span class="lineNoCov">          0 : inline bool IsDigit(char ch) {</span>
<a name="1666"><span class="lineNum">    1666 </span><span class="lineNoCov">          0 :   return isdigit(static_cast&lt;unsigned char&gt;(ch)) != 0;</span></a>
<span class="lineNum">    1667 </span>            : }
<span class="lineNum">    1668 </span><span class="lineNoCov">          0 : inline bool IsLower(char ch) {</span>
<a name="1669"><span class="lineNum">    1669 </span><span class="lineNoCov">          0 :   return islower(static_cast&lt;unsigned char&gt;(ch)) != 0;</span></a>
<span class="lineNum">    1670 </span>            : }
<span class="lineNum">    1671 </span><span class="lineNoCov">          0 : inline bool IsSpace(char ch) {</span>
<a name="1672"><span class="lineNum">    1672 </span><span class="lineNoCov">          0 :   return isspace(static_cast&lt;unsigned char&gt;(ch)) != 0;</span></a>
<span class="lineNum">    1673 </span>            : }
<span class="lineNum">    1674 </span><span class="lineNoCov">          0 : inline bool IsUpper(char ch) {</span>
<a name="1675"><span class="lineNum">    1675 </span><span class="lineNoCov">          0 :   return isupper(static_cast&lt;unsigned char&gt;(ch)) != 0;</span></a>
<span class="lineNum">    1676 </span>            : }
<span class="lineNum">    1677 </span><span class="lineNoCov">          0 : inline bool IsXDigit(char ch) {</span>
<a name="1678"><span class="lineNum">    1678 </span><span class="lineNoCov">          0 :   return isxdigit(static_cast&lt;unsigned char&gt;(ch)) != 0;</span></a>
<span class="lineNum">    1679 </span>            : }
<span class="lineNum">    1680 </span><span class="lineNoCov">          0 : inline bool IsXDigit(wchar_t ch) {</span>
<span class="lineNum">    1681 </span><span class="lineNoCov">          0 :   const unsigned char low_byte = static_cast&lt;unsigned char&gt;(ch);</span>
<span class="lineNum">    1682 </span><span class="lineNoCov">          0 :   return ch == low_byte &amp;&amp; isxdigit(low_byte) != 0;</span>
<a name="1683"><span class="lineNum">    1683 </span>            : }</a>
<span class="lineNum">    1684 </span>            : 
<span class="lineNum">    1685 </span><span class="lineNoCov">          0 : inline char ToLower(char ch) {</span>
<a name="1686"><span class="lineNum">    1686 </span><span class="lineNoCov">          0 :   return static_cast&lt;char&gt;(tolower(static_cast&lt;unsigned char&gt;(ch)));</span></a>
<span class="lineNum">    1687 </span>            : }
<span class="lineNum">    1688 </span><span class="lineNoCov">          0 : inline char ToUpper(char ch) {</span>
<span class="lineNum">    1689 </span><span class="lineNoCov">          0 :   return static_cast&lt;char&gt;(toupper(static_cast&lt;unsigned char&gt;(ch)));</span>
<span class="lineNum">    1690 </span>            : }
<span class="lineNum">    1691 </span>            : 
<span class="lineNum">    1692 </span>            : // The testing::internal::posix namespace holds wrappers for common
<span class="lineNum">    1693 </span>            : // POSIX functions.  These wrappers hide the differences between
<span class="lineNum">    1694 </span>            : // Windows/MSVC and POSIX systems.  Since some compilers define these
<span class="lineNum">    1695 </span>            : // standard functions as macros, the wrapper cannot have the same name
<span class="lineNum">    1696 </span>            : // as the wrapped function.
<span class="lineNum">    1697 </span>            : 
<span class="lineNum">    1698 </span>            : namespace posix {
<span class="lineNum">    1699 </span>            : 
<span class="lineNum">    1700 </span>            : // Functions with a different name on Windows.
<span class="lineNum">    1701 </span>            : 
<span class="lineNum">    1702 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">    1703 </span>            : 
<span class="lineNum">    1704 </span>            : typedef struct _stat StatStruct;
<span class="lineNum">    1705 </span>            : 
<span class="lineNum">    1706 </span>            : # ifdef __BORLANDC__
<span class="lineNum">    1707 </span>            : inline int IsATTY(int fd) { return isatty(fd); }
<span class="lineNum">    1708 </span>            : inline int StrCaseCmp(const char* s1, const char* s2) {
<span class="lineNum">    1709 </span>            :   return stricmp(s1, s2);
<span class="lineNum">    1710 </span>            : }
<span class="lineNum">    1711 </span>            : inline char* StrDup(const char* src) { return strdup(src); }
<span class="lineNum">    1712 </span>            : # else  // !__BORLANDC__
<span class="lineNum">    1713 </span>            : #  if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1714 </span>            : inline int IsATTY(int /* fd */) { return 0; }
<span class="lineNum">    1715 </span>            : #  else
<span class="lineNum">    1716 </span>            : inline int IsATTY(int fd) { return _isatty(fd); }
<span class="lineNum">    1717 </span>            : #  endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1718 </span>            : inline int StrCaseCmp(const char* s1, const char* s2) {
<span class="lineNum">    1719 </span>            :   return _stricmp(s1, s2);
<span class="lineNum">    1720 </span>            : }
<span class="lineNum">    1721 </span>            : inline char* StrDup(const char* src) { return _strdup(src); }
<span class="lineNum">    1722 </span>            : # endif  // __BORLANDC__
<span class="lineNum">    1723 </span>            : 
<span class="lineNum">    1724 </span>            : # if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1725 </span>            : inline int FileNo(FILE* file) { return reinterpret_cast&lt;int&gt;(_fileno(file)); }
<span class="lineNum">    1726 </span>            : // Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
<span class="lineNum">    1727 </span>            : // time and thus not defined there.
<span class="lineNum">    1728 </span>            : # else
<span class="lineNum">    1729 </span>            : inline int FileNo(FILE* file) { return _fileno(file); }
<span class="lineNum">    1730 </span>            : inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
<span class="lineNum">    1731 </span>            : inline int RmDir(const char* dir) { return _rmdir(dir); }
<span class="lineNum">    1732 </span>            : inline bool IsDir(const StatStruct&amp; st) {
<span class="lineNum">    1733 </span>            :   return (_S_IFDIR &amp; st.st_mode) != 0;
<span class="lineNum">    1734 </span>            : }
<span class="lineNum">    1735 </span>            : # endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1736 </span>            : 
<span class="lineNum">    1737 </span>            : #else
<span class="lineNum">    1738 </span>            : 
<a name="1739"><span class="lineNum">    1739 </span>            : typedef struct stat StatStruct;</a>
<a name="1740"><span class="lineNum">    1740 </span>            : </a>
<a name="1741"><span class="lineNum">    1741 </span><span class="lineNoCov">          0 : inline int FileNo(FILE* file) { return fileno(file); }</span></a>
<a name="1742"><span class="lineNum">    1742 </span><span class="lineNoCov">          0 : inline int IsATTY(int fd) { return isatty(fd); }</span></a>
<span class="lineNum">    1743 </span><span class="lineNoCov">          0 : inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }</span>
<span class="lineNum">    1744 </span><span class="lineNoCov">          0 : inline int StrCaseCmp(const char* s1, const char* s2) {</span>
<a name="1745"><span class="lineNum">    1745 </span><span class="lineNoCov">          0 :   return strcasecmp(s1, s2);</span></a>
<span class="lineNum">    1746 </span>            : }
<a name="1747"><span class="lineNum">    1747 </span><span class="lineNoCov">          0 : inline char* StrDup(const char* src) { return strdup(src); }</span></a>
<span class="lineNum">    1748 </span>            : inline int RmDir(const char* dir) { return rmdir(dir); }
<span class="lineNum">    1749 </span><span class="lineNoCov">          0 : inline bool IsDir(const StatStruct&amp; st) { return S_ISDIR(st.st_mode); }</span>
<span class="lineNum">    1750 </span>            : 
<span class="lineNum">    1751 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">    1752 </span>            : 
<span class="lineNum">    1753 </span>            : // Functions deprecated by MSVC 8.0.
<span class="lineNum">    1754 </span>            : 
<span class="lineNum">    1755 </span>            : #ifdef _MSC_VER
<span class="lineNum">    1756 </span>            : // Temporarily disable warning 4996 (deprecated function).
<span class="lineNum">    1757 </span>            : # pragma warning(push)
<span class="lineNum">    1758 </span>            : # pragma warning(disable:4996)
<span class="lineNum">    1759 </span>            : #endif
<span class="lineNum">    1760 </span>            : 
<span class="lineNum">    1761 </span>            : inline const char* StrNCpy(char* dest, const char* src, size_t n) {
<span class="lineNum">    1762 </span>            :   return strncpy(dest, src, n);
<span class="lineNum">    1763 </span>            : }
<span class="lineNum">    1764 </span>            : 
<span class="lineNum">    1765 </span>            : // ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
<span class="lineNum">    1766 </span>            : // StrError() aren't needed on Windows CE at this time and thus not
<span class="lineNum">    1767 </span>            : // defined there.
<span class="lineNum">    1768 </span>            : 
<span class="lineNum">    1769 </span>            : #if !GTEST_OS_WINDOWS_MOBILE
<a name="1770"><span class="lineNum">    1770 </span>            : inline int ChDir(const char* dir) { return chdir(dir); }</a>
<span class="lineNum">    1771 </span>            : #endif
<span class="lineNum">    1772 </span><span class="lineNoCov">          0 : inline FILE* FOpen(const char* path, const char* mode) {</span>
<span class="lineNum">    1773 </span><span class="lineNoCov">          0 :   return fopen(path, mode);</span>
<span class="lineNum">    1774 </span>            : }
<span class="lineNum">    1775 </span>            : #if !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1776 </span>            : inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
<a name="1777"><span class="lineNum">    1777 </span>            :   return freopen(path, mode, stream);</a>
<span class="lineNum">    1778 </span>            : }
<a name="1779"><span class="lineNum">    1779 </span><span class="lineNoCov">          0 : inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }</span></a>
<span class="lineNum">    1780 </span>            : #endif
<a name="1781"><span class="lineNum">    1781 </span><span class="lineNoCov">          0 : inline int FClose(FILE* fp) { return fclose(fp); }</span></a>
<span class="lineNum">    1782 </span>            : #if !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1783 </span><span class="lineNoCov">          0 : inline int Read(int fd, void* buf, unsigned int count) {</span>
<a name="1784"><span class="lineNum">    1784 </span><span class="lineNoCov">          0 :   return static_cast&lt;int&gt;(read(fd, buf, count));</span></a>
<span class="lineNum">    1785 </span>            : }
<span class="lineNum">    1786 </span><span class="lineNoCov">          0 : inline int Write(int fd, const void* buf, unsigned int count) {</span>
<a name="1787"><span class="lineNum">    1787 </span><span class="lineNoCov">          0 :   return static_cast&lt;int&gt;(write(fd, buf, count));</span></a>
<a name="1788"><span class="lineNum">    1788 </span>            : }</a>
<span class="lineNum">    1789 </span><span class="lineNoCov">          0 : inline int Close(int fd) { return close(fd); }</span>
<a name="1790"><span class="lineNum">    1790 </span><span class="lineNoCov">          0 : inline const char* StrError(int errnum) { return strerror(errnum); }</span></a>
<span class="lineNum">    1791 </span>            : #endif
<span class="lineNum">    1792 </span><span class="lineNoCov">          0 : inline const char* GetEnv(const char* name) {</span>
<span class="lineNum">    1793 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1794 </span>            :   // We are on Windows CE, which has no environment variables.
<span class="lineNum">    1795 </span>            :   return NULL;
<span class="lineNum">    1796 </span>            : #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
<span class="lineNum">    1797 </span>            :   // Environment variables which we programmatically clear will be set to the
<span class="lineNum">    1798 </span>            :   // empty string rather than unset (NULL).  Handle that case.
<span class="lineNum">    1799 </span>            :   const char* const env = getenv(name);
<span class="lineNum">    1800 </span>            :   return (env != NULL &amp;&amp; env[0] != '\0') ? env : NULL;
<span class="lineNum">    1801 </span>            : #else
<span class="lineNum">    1802 </span><span class="lineNoCov">          0 :   return getenv(name);</span>
<span class="lineNum">    1803 </span>            : #endif
<span class="lineNum">    1804 </span>            : }
<span class="lineNum">    1805 </span>            : 
<span class="lineNum">    1806 </span>            : #ifdef _MSC_VER
<span class="lineNum">    1807 </span>            : # pragma warning(pop)  // Restores the warning state.
<span class="lineNum">    1808 </span>            : #endif
<span class="lineNum">    1809 </span>            : 
<span class="lineNum">    1810 </span>            : #if GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1811 </span>            : // Windows CE has no C library. The abort() function is used in
<span class="lineNum">    1812 </span>            : // several places in Google Test. This implementation provides a reasonable
<span class="lineNum">    1813 </span>            : // imitation of standard behaviour.
<a name="1814"><span class="lineNum">    1814 </span>            : void Abort();</a>
<span class="lineNum">    1815 </span>            : #else
<span class="lineNum">    1816 </span><span class="lineNoCov">          0 : inline void Abort() { abort(); }</span>
<span class="lineNum">    1817 </span>            : #endif  // GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1818 </span>            : 
<span class="lineNum">    1819 </span>            : }  // namespace posix
<span class="lineNum">    1820 </span>            : 
<span class="lineNum">    1821 </span>            : // MSVC &quot;deprecates&quot; snprintf and issues warnings wherever it is used.  In
<span class="lineNum">    1822 </span>            : // order to avoid these warnings, we need to use _snprintf or _snprintf_s on
<span class="lineNum">    1823 </span>            : // MSVC-based platforms.  We map the GTEST_SNPRINTF_ macro to the appropriate
<span class="lineNum">    1824 </span>            : // function in order to achieve that.  We use macro definition here because
<span class="lineNum">    1825 </span>            : // snprintf is a variadic function.
<span class="lineNum">    1826 </span>            : #if _MSC_VER &gt;= 1400 &amp;&amp; !GTEST_OS_WINDOWS_MOBILE
<span class="lineNum">    1827 </span>            : // MSVC 2005 and above support variadic macros.
<span class="lineNum">    1828 </span>            : # define GTEST_SNPRINTF_(buffer, size, format, ...) \
<span class="lineNum">    1829 </span>            :      _snprintf_s(buffer, size, size, format, __VA_ARGS__)
<span class="lineNum">    1830 </span>            : #elif defined(_MSC_VER)
<span class="lineNum">    1831 </span>            : // Windows CE does not define _snprintf_s and MSVC prior to 2005 doesn't
<span class="lineNum">    1832 </span>            : // complain about _snprintf.
<span class="lineNum">    1833 </span>            : # define GTEST_SNPRINTF_ _snprintf
<span class="lineNum">    1834 </span>            : #else
<span class="lineNum">    1835 </span>            : # define GTEST_SNPRINTF_ snprintf
<span class="lineNum">    1836 </span>            : #endif
<span class="lineNum">    1837 </span>            : 
<span class="lineNum">    1838 </span>            : // The maximum number a BiggestInt can represent.  This definition
<span class="lineNum">    1839 </span>            : // works no matter BiggestInt is represented in one's complement or
<span class="lineNum">    1840 </span>            : // two's complement.
<span class="lineNum">    1841 </span>            : //
<span class="lineNum">    1842 </span>            : // We cannot rely on numeric_limits in STL, as __int64 and long long
<span class="lineNum">    1843 </span>            : // are not part of standard C++ and numeric_limits doesn't need to be
<span class="lineNum">    1844 </span>            : // defined for them.
<span class="lineNum">    1845 </span>            : const BiggestInt kMaxBiggestInt =
<span class="lineNum">    1846 </span>            :     ~(static_cast&lt;BiggestInt&gt;(1) &lt;&lt; (8*sizeof(BiggestInt) - 1));
<span class="lineNum">    1847 </span>            : 
<span class="lineNum">    1848 </span>            : // This template class serves as a compile-time function from size to
<span class="lineNum">    1849 </span>            : // type.  It maps a size in bytes to a primitive type with that
<span class="lineNum">    1850 </span>            : // size. e.g.
<span class="lineNum">    1851 </span>            : //
<span class="lineNum">    1852 </span>            : //   TypeWithSize&lt;4&gt;::UInt
<span class="lineNum">    1853 </span>            : //
<span class="lineNum">    1854 </span>            : // is typedef-ed to be unsigned int (unsigned integer made up of 4
<span class="lineNum">    1855 </span>            : // bytes).
<span class="lineNum">    1856 </span>            : //
<span class="lineNum">    1857 </span>            : // Such functionality should belong to STL, but I cannot find it
<span class="lineNum">    1858 </span>            : // there.
<span class="lineNum">    1859 </span>            : //
<span class="lineNum">    1860 </span>            : // Google Test uses this class in the implementation of floating-point
<span class="lineNum">    1861 </span>            : // comparison.
<span class="lineNum">    1862 </span>            : //
<span class="lineNum">    1863 </span>            : // For now it only handles UInt (unsigned int) as that's all Google Test
<span class="lineNum">    1864 </span>            : // needs.  Other types can be easily added in the future if need
<span class="lineNum">    1865 </span>            : // arises.
<span class="lineNum">    1866 </span>            : template &lt;size_t size&gt;
<span class="lineNum">    1867 </span>            : class TypeWithSize {
<span class="lineNum">    1868 </span>            :  public:
<span class="lineNum">    1869 </span>            :   // This prevents the user from using TypeWithSize&lt;N&gt; with incorrect
<span class="lineNum">    1870 </span>            :   // values of N.
<span class="lineNum">    1871 </span>            :   typedef void UInt;
<span class="lineNum">    1872 </span>            : };
<span class="lineNum">    1873 </span>            : 
<span class="lineNum">    1874 </span>            : // The specialization for size 4.
<span class="lineNum">    1875 </span>            : template &lt;&gt;
<span class="lineNum">    1876 </span>            : class TypeWithSize&lt;4&gt; {
<span class="lineNum">    1877 </span>            :  public:
<span class="lineNum">    1878 </span>            :   // unsigned int has size 4 in both gcc and MSVC.
<span class="lineNum">    1879 </span>            :   //
<span class="lineNum">    1880 </span>            :   // As base/basictypes.h doesn't compile on Windows, we cannot use
<span class="lineNum">    1881 </span>            :   // uint32, uint64, and etc here.
<span class="lineNum">    1882 </span>            :   typedef int Int;
<span class="lineNum">    1883 </span>            :   typedef unsigned int UInt;
<span class="lineNum">    1884 </span>            : };
<span class="lineNum">    1885 </span>            : 
<span class="lineNum">    1886 </span>            : // The specialization for size 8.
<span class="lineNum">    1887 </span>            : template &lt;&gt;
<span class="lineNum">    1888 </span>            : class TypeWithSize&lt;8&gt; {
<span class="lineNum">    1889 </span>            :  public:
<span class="lineNum">    1890 </span>            : #if GTEST_OS_WINDOWS
<span class="lineNum">    1891 </span>            :   typedef __int64 Int;
<span class="lineNum">    1892 </span>            :   typedef unsigned __int64 UInt;
<span class="lineNum">    1893 </span>            : #else
<span class="lineNum">    1894 </span>            :   typedef long long Int;  // NOLINT
<span class="lineNum">    1895 </span>            :   typedef unsigned long long UInt;  // NOLINT
<span class="lineNum">    1896 </span>            : #endif  // GTEST_OS_WINDOWS
<span class="lineNum">    1897 </span>            : };
<span class="lineNum">    1898 </span>            : 
<span class="lineNum">    1899 </span>            : // Integer types of known sizes.
<span class="lineNum">    1900 </span>            : typedef TypeWithSize&lt;4&gt;::Int Int32;
<span class="lineNum">    1901 </span>            : typedef TypeWithSize&lt;4&gt;::UInt UInt32;
<span class="lineNum">    1902 </span>            : typedef TypeWithSize&lt;8&gt;::Int Int64;
<span class="lineNum">    1903 </span>            : typedef TypeWithSize&lt;8&gt;::UInt UInt64;
<span class="lineNum">    1904 </span>            : typedef TypeWithSize&lt;8&gt;::Int TimeInMillis;  // Represents time in milliseconds.
<span class="lineNum">    1905 </span>            : 
<span class="lineNum">    1906 </span>            : // Utilities for command line flags and environment variables.
<span class="lineNum">    1907 </span>            : 
<span class="lineNum">    1908 </span>            : // Macro for referencing flags.
<span class="lineNum">    1909 </span>            : #define GTEST_FLAG(name) FLAGS_gtest_##name
<span class="lineNum">    1910 </span>            : 
<span class="lineNum">    1911 </span>            : // Macros for declaring flags.
<span class="lineNum">    1912 </span>            : #define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
<span class="lineNum">    1913 </span>            : #define GTEST_DECLARE_int32_(name) \
<span class="lineNum">    1914 </span>            :     GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
<span class="lineNum">    1915 </span>            : #define GTEST_DECLARE_string_(name) \
<span class="lineNum">    1916 </span>            :     GTEST_API_ extern ::std::string GTEST_FLAG(name)
<span class="lineNum">    1917 </span>            : 
<span class="lineNum">    1918 </span>            : // Macros for defining flags.
<span class="lineNum">    1919 </span>            : #define GTEST_DEFINE_bool_(name, default_val, doc) \
<span class="lineNum">    1920 </span>            :     GTEST_API_ bool GTEST_FLAG(name) = (default_val)
<span class="lineNum">    1921 </span>            : #define GTEST_DEFINE_int32_(name, default_val, doc) \
<span class="lineNum">    1922 </span>            :     GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
<span class="lineNum">    1923 </span>            : #define GTEST_DEFINE_string_(name, default_val, doc) \
<span class="lineNum">    1924 </span>            :     GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
<span class="lineNum">    1925 </span>            : 
<span class="lineNum">    1926 </span>            : // Thread annotations
<span class="lineNum">    1927 </span>            : #define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
<span class="lineNum">    1928 </span>            : #define GTEST_LOCK_EXCLUDED_(locks)
<span class="lineNum">    1929 </span>            : 
<span class="lineNum">    1930 </span>            : // Parses 'str' for a 32-bit signed integer.  If successful, writes the result
<span class="lineNum">    1931 </span>            : // to *value and returns true; otherwise leaves *value unchanged and returns
<span class="lineNum">    1932 </span>            : // false.
<span class="lineNum">    1933 </span>            : // TODO(chandlerc): Find a better way to refactor flag and environment parsing
<span class="lineNum">    1934 </span>            : // out of both gtest-port.cc and gtest.cc to avoid exporting this utility
<span class="lineNum">    1935 </span>            : // function.
<span class="lineNum">    1936 </span>            : bool ParseInt32(const Message&amp; src_text, const char* str, Int32* value);
<span class="lineNum">    1937 </span>            : 
<span class="lineNum">    1938 </span>            : // Parses a bool/Int32/string from the environment variable
<span class="lineNum">    1939 </span>            : // corresponding to the given Google Test flag.
<span class="lineNum">    1940 </span>            : bool BoolFromGTestEnv(const char* flag, bool default_val);
<span class="lineNum">    1941 </span>            : GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
<span class="lineNum">    1942 </span>            : const char* StringFromGTestEnv(const char* flag, const char* default_val);
<span class="lineNum">    1943 </span>            : 
<span class="lineNum">    1944 </span>            : }  // namespace internal
<span class="lineNum">    1945 </span>            : }  // namespace testing
<span class="lineNum">    1946 </span>            : 
<span class="lineNum">    1947 </span>            : #endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
